Reputation: 217
So I want to take the first letter of the first name and all of the last name, add them together and make that the person's username.
I was using CONCAT() and I keep getting an unexplained syntax error from MySQL.
I have:
SELECT
CONCAT(left(first_name, 1), left(last_name)) username
FROM survey_responders;
And all I get is "Syntax Error" as my error. What am I doing wrong?
Upvotes: 0
Views: 54
Reputation: 68
The function left is good but substr is more efficient, try this instead:
select concat(substr(first_name, 1, 1), last_name) username
FROM survey_responders;
Upvotes: 0
Reputation: 11084
You are missing the second argument for left(last_name), but I don't even think you need that call to left since you want the whole thing. So:
SELECT
CONCAT(left(first_name, 1), last_name) username
FROM survey_responders;
Upvotes: 1