10

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

2 Answers 2

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

Read this tutorial:

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

Sign up to request clarification or add additional context in comments.

Comments

4

There is a CONCAT function in mysql.

select concat('The Year is ', year), concat('The month is ', month) from time where rownum < 2;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.