My question was to take the first letter of a survey responders first name and the first letter of the responders last name and concatenate the two so I get something along the lines of this: Sam Smith's would result in SS.
I'm using this query to do that and get the result I needed:
select concat(letterfirst, letterlast) as users
from (select substring(first_name,1,1) as letterfirst,
substring(last_name,1,1) as letterlast
from survey_responders) as user1
Now I need to pass that result into the username column in the same table, survey_responders. I know I have to use a update statement but I can't seem to wrap my head around using a select statement with an update.
答案 0 :(得分:3)
You are overcomplicating the situation:
update survey_responders
set username = concat(left(first_name, 1), left(last_name, 1));