2010-10-14 36 views
6

在MySQL中使用SELECT語句將文本連接到值的方法是什麼? (如在甲骨文)mysql - 在SELECT子句中添加/連接文本值

例如,在Oracle中,你可以寫這樣的事情:

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 

回答

3

有一個CONCAT功能MySQL的。

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

感謝您的提示! – jdamae 2010-10-14 05:19:34