Possible Duplicate:
How to insert the next highest number into the database
I am using MYSQL
I have a column known as TeacherId which is auto incremented and goes like this:
TeacherId
1
2
3
4
What I want to do is add the letter ‘T’ in front of the numbers so it becomes:
TeacherId
T1
T2
T3
T4
How can I update or alter table to do this?
Below is my attempt but it did not work:
UPDATE Teacher SET TeacherId = CONCAT('T',TeacherId)
I highly recommend you consider appending the T to the display at query time instead of trying to store a T on every single row. I don’t understand the purpose of storing the data this way, particularly if you have other tables that use the TeacherId value in its native form.
If you need to distinguish teachers from admins, then two thoughts:
I know you might have been told that it should show as T3 etc., but surely they did not tell you explicitly “we want you to store the T and 3 together in the same column, or else.” You can show them T3 without shoehorning them together in a terrible and unusable design.