/* result 1 */
select Id, Name
from Items
/* result 2 */
select Id,
Alias
from ItemAliases
where Id in (
select Id, Name
from table abc
)
We use SQL Server 2008.
Using the above example, it should be pretty straightforward what I'm trying to do.
I need to return the results of query 1... and return the results of query 2.
Query 2 however, needs to filter to only include records from result 1.
Here is my attempt to show what I would like to end up with.
VAR A = (
select Id, Name
from Items
)
/* result 1 */
select A.*
/* result 2 */
select Id,
Alias
from ItemAliases
where Id in ( A.Id )
I think you just want to store Result1 and use it to compose Result2: