编写一个查询,将员工ID与员工姓名中的前3个字符连接起来。使用别名显示为official_mail并按升序排列结果。
我的代码:
select staff_id as official_mail
from Staff
order by official_mail;
如何写前3个字符?
答案 0 :(得分:0)
对于MySQL / MSSQL
SELECT CONCAT(staff_id,SUBSTRING(staff_name,1,3)) AS official_mail
FROM Staff
ORDER BY official_mail;
现场演示