Reputation: 1518
I am trying to add two columns as one column by using this statement
SELECT (member_Firstname+''+member_Lastname) AS Name FROM members
but it gives all 0 values in mysql workbench
Upvotes: 3
Views: 111
Reputation: 4179
SELECT concat(member_Firstname,'',member_Lastname) AS Name FROM members;
This should work always
Upvotes: 7
Reputation: 168685
Adding is for numbers; for joining strings, use concat()
SELECT CONCAT(string1,string2,string3,etc) FROM table
Upvotes: 1
Reputation: 15433
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);
Upvotes: 0
Reputation: 2276
I think that in MySQL you should use CONCAT, as follows:
mysql> SELECT CONCAT('My', 'S', 'QL'); -> 'MySQL'
Upvotes: 2