Within a table in my database I have a table which holds IDs (Integers) for each customer.
Different customers come from different countries and i would like to prefix their ‘ID’ with two characters.
Say I had a customer with an ID of 12345.
How would I add the prefix ‘EN’ to that customer number?
I’m aware I can CAST() on a variable, however is this process the same for a field acquired through a query?
You would just concatenate the characters
Then if you want to do an update:
If you have the list of countries in the table:
or
See SQL Fiddle with Demo