我的问题是采取调查响应者名字的第一个字母和响应者姓氏的第一个字母,并将两者连接起来,所以我得到的结论是:Sam Smith将导致SS。
我正在使用此查询来执行此操作并获得我需要的结果:
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
现在我需要将该结果传递到同一个表的survey_responders中的用户名列。我知道我必须使用更新语句,但我似乎无法使用带有更新的select语句。
你的情况太复杂了:
update survey_responders
set username = concat(left(first_name, 1), left(last_name, 1));