.

.

How To Combine Two or more column in mysql Database

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.
How to combine two or more column in mysql database,combine two or more column in mysql database,two or more column in mysql database,more column in mysql database,column in mysql database,


Create the column:
alter table add column combined varchar(50);

Update the current values:
update tablename set combined = concat(zipcode, ' - ', city, ', ', state);


EmoticonEmoticon