开发者

sql columns adding

开发者 https://www.devze.com 2023-03-13 07:52 出处:网络
I am trying to add two columns as one column by using this statement SELECT (member_Firstname+\'\'+membe开发者_运维百科r_Lastname) AS Name FROM members

I am trying to add two columns as one column by using this statement

SELECT (member_Firstname+''+membe开发者_运维百科r_Lastname) AS Name FROM members

but it gives all 0 values in mysql workbench


SELECT concat(member_Firstname,'',member_Lastname) AS Name FROM members;

This should work always


I think that in MySQL you should use CONCAT, as follows:

mysql> SELECT CONCAT('My', 'S', 'QL'); -> 'MySQL'


Adding is for numbers; for joining strings, use concat()

SELECT CONCAT(string1,string2,string3,etc) FROM table


SELECT CONCAT(CAST(int_col AS CHAR), char_col);

CONCAT() returns NULL if any argument is NULL.

So for the example

SELECT CONCAT(member_Firstname, member_Lastname);
0

精彩评论

暂无评论...
验证码 换一张
取 消