2010-04-18 93 views

回答

3

完全可以接受的 - 計算或在MySQL衍生字段例如

select 
    c.firstname, 
    c.lastname, 
    concat(c.firstname, ' ', c.lastname) as fullname 
from 
    customer c 
where 
    c.cust_id = 1; 
+0

在PHP的concat fn對我來說很好。感謝播種這個想法。 <?php $ str1 ='This'; $ str2 ='是a'; $ str3 ='test string'; $ full = $ str1。$ str2。$ str3; echo $ full; ?> – 2010-04-19 00:11:21

+0

+1一個很好的與語言無關的答案:)無論PHP,Perl,Python,Java等用作應用程序的語言,該解決方案都可用於任何MySQL設置。 – therobyouknow 2011-12-06 10:11:44

-1

不,數據庫或php都不會注意到這個操作。
更好的做在PHP中,因爲它會很多可讀。

4

取決於數據庫,MySQL中可以使用功能 CONCAT

例如,UPDATE users SET NAME=CONCAT('asd', 'asdfac') WHERE id=2;

相關問題