由于子查询返回多个值,因此无法设置@parameter
。如果我使用SELECT TOP 1 Name
则可行。我该如何解决?
DECLARE @parameter nvarchar(50)
SELECT @parameter = (SELECT Name FROM Choices
JOIN Position ON Position.PositionId = Choices.PositionId
WHERE Choices.CvId=1230)
SELECT * FROM Adverts WHERE Name LIKE '%' + @parameter + '%'
答案 0 :(得分:2)
为什么不将2个查询合并为1?
select a.*
from Choices c
inner join Position p on c.PositionId = p.PositionId
inner join Adverts a on p.Name like '%' + a.Name + '%'
where c.CvID = 1230