String combining operations in select

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Shendemiar
Forum Contributor
Posts: 404
Joined: Thu Jan 08, 2004 8:28 am

String combining operations in select

Post by Shendemiar »

MySql

Can I select, say 2 columns to result as one, using + etc.

In php terms

Code: Select all

"text1"."text2"
Something like

Code: Select all

SELECT (a+b) as newstring FROM...
User avatar
aaronhall
DevNet Resident
Posts: 1040
Joined: Tue Aug 13, 2002 5:10 pm
Location: Back in Phoenix, missing the microbrews
Contact:

Post by aaronhall »

Code: Select all

SELECT CONCAT(field1, " ", field2) FROM table
Will concatenate the two fields, and add a space in between
Post Reply