MySQL Forums
Forum List  »  InnoDB

Re: Query to combine columns
Posted by: Rick James
Date: April 05, 2013 10:20PM

SELECT col1, col2, COnCAT(col1, col2) FROM tbl;

Example:
mysql> SELECT city, state, CONCAT(city, state)
        FROM US ORDER BY RAND() LIMIT 11;
+-----------------+-------+---------------------+
| city            | state | CONCAT(city, state) |
+-----------------+-------+---------------------+
| Palatine        | IL    | PalatineIL          |
| Lindsay         | CA    | LindsayCA           |
| Hempstead       | NY    | HempsteadNY         |
| Alderwood Manor | WA    | Alderwood ManorWA   |
| Taft            | CA    | TaftCA              |
| Beaufort        | SC    | BeaufortSC          |
| Madison Heights | VA    | Madison HeightsVA   |
| Seminole        | FL    | SeminoleFL          |
| Longmont        | CO    | LongmontCO          |
| White Oak       | MD    | White OakMD         |
| Douglas         | GA    | DouglasGA           |
+-----------------+-------+---------------------+

Options: ReplyQuote


Subject
Views
Written By
Posted
1078
April 04, 2013 11:49PM
Re: Query to combine columns
638
April 05, 2013 10:20PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.