2010-04-18 94 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;

相关问题