To concat or combine two or more column in mysql database.I have the following structure with a MySQL table:
+----------------+----------------+----------+
| zipcode | city | state |
+----------------+----------------+----------+
| 10954 | Nanuet | NY |
+----------------+----------------+----------+
I want to combine the above 3 columns into one column like this:
+---------------------+
| combined |
+---------------------+
| 10954 - Nanuet, NY |
+---------------------+
And I want to add this "combined" column to the end of the table without destroying the original 3 fields.
Create the column:
alter table add column combined varchar(50);
Update the current values:
update tablename set combined = concat(zipcode, ' - ', city, ', ', state);
EmoticonEmoticon