Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql - adding/concatenating text values within a SELECT clause

Is there a way in MySQL to concatenate text to values using a SELECT statement? (like in Oracle)

For example, in Oracle you can write something like this:

SQL> select 'The Year is '|| year, 'The month is '|| month from time where rownum < 2;

'THEYEARIS'||YEAR
----------------------------------------------------
'THEMONTHIS'||MONTH
-----------------------------------------------------
The Year is 2009
The month is 1
like image 748
jdamae Avatar asked Oct 14 '10 05:10

jdamae


1 Answers

SELECT Concat(vend_name, ' (', vend_country, ')')
FROM vendors
ORDER BY vend_name;

Read this tutorial:

http://www.brainbell.com/tutorials/MySQL/Concatenating_Fields.htm

like image 153
Trufa Avatar answered Nov 03 '22 02:11

Trufa