将两个SQL查询放入同一个表中
SELECT FirstName,
LastName,
LEFT(FirstName, 1) + '.' + LEFT(LastName, 1) AS Initial
FROM ContactUpdates
输出:
FirstName LastName Initial
我想在初始结束
的右侧加入另一个SELECT LOWER(LEFT(FirstName, 1) + REPLACE(LastName,'''','' ) )
+ '@email.com' AS Email
FROM ContactUpdates
最后我希望它是
FirstName LastName Initial Email
但我无法弄清楚如何让他们加入任何帮助?
答案 0 :(得分:2)
SELECT FirstName,
LastName,
LEFT(FirstName,1) + '.' + LEFT(LastName,1) AS Initial,
LOWER(LEFT(FirstName, 1) + REPLACE(LastName, '''', '')) + '@email.com' AS Email
FROM ContactUpdates
答案 1 :(得分:2)
然后只需将该列附加到查询中:
SELECT FirstName
, LastName
, LEFT(FirstName,1) + '.' + LEFT(LastName,1) AS Initial
, LOWER(LEFT(FirstName,1) + REPLACE(LastName,'''','' ) ) + '@email.com' AS Email
FROM ContactUpdates