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);
精彩评论