我有一个场景,我想在数据库中提取的所有值的开头附加一个字符串'rajat'。查询看起来像
('rajat' + (SELECT a FROM b
WHERE b >= (SELECT TOP 1 c FROM d ORDER BY e DESC)))
但这似乎不起作用。
答案 0 :(得分:2)
SELECT a = 'rajat' + tableB.a
FROM dbo.b tableB
WHERE tableB.b >= (SELECT TOP 1 c FROM d ORDER BY e DESC)
答案 1 :(得分:0)
假设列a
SELECT 'rajat ' + cast(a as varchar(50)) as a
WHERE b >= (SELECT TOP 1 c FROM d ORDER BY e DESC)
如果列a是varchar,则简单直接。
SELECT 'rajat ' + a as a
WHERE b >= (SELECT TOP 1 c FROM d ORDER BY e DESC)