I have a SQL query where I have in my where clause a list into a IN condition.
Example of what I mean:
WHERE Id IN (11111,11112)
And what I try to do is the following: I have a linked server query where I have an IN clause.
And I have a subquery where I use a JOIN table to cross data but I need that in the IN condition use the same Id like the main query.
I hope you guys understand what I try to do:
Here's my code:
SELECT
Name,
Street,
Number,
(SELECT loginUser FROM [LinkedServer].[Database].[dbo].[Users] T1
INNER JOIN [LinkedServer].[Database].[dbo].[General] T2
ON T2.IdUser = T1.Id
WHERE T2.Id IN (11111,11112,11113,11114,11115)
)
FROM [LinkedServer].[Database].[dbo].[General]
WHERE Id IN (11111,11112,11113,11114,11115)
i get this error:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.