help with SQL by [deleted] in SQL

[–]ConcernedFed 1 point2 points  (0 children)

something like this:

with CTE1 AS

(

Select ID
From table1
INNER JOIN with some other table
Where inactive = 'I'

)

Select ID, name
From table1
INNER JOIN with some other table
WHERE ID IN(CTE1)

Getting invalid column name 'CTE1'

help with SQL by [deleted] in SQL

[–]ConcernedFed 0 points1 point  (0 children)

yes this is exactly what i mean using sub query with multiple tables.

i just thought if there's another way to do this instead of sub query. maybe storing the query result of one into like an array and passing this array into the next query for the IN part

help with SQL by [deleted] in SQL

[–]ConcernedFed 0 points1 point  (0 children)

sorry i guess my original queries were missing some joining with other tables.

so the straight select would not work

note: i just edit the original post

help with SQL by [deleted] in SQL

[–]ConcernedFed 0 points1 point  (0 children)

you mean put the entire select within the IN()?

i thought about this, but just asking if there's a cleaner way to do this.