Link to home
Start Free TrialLog in
Avatar of Webbo_1980
Webbo_1980

asked on

How do i get the contents/Id of a of a field for a nested query if its contained in a parent query

I've got the following query i.e.

INSERT INTO Table1(value1,value2,value3)
      SELECT ID, * FROM Table2
      WHERE Column2 NOT IN
      (
            SELECT DISTINCT ID FROM [Table3]
            WHERE [column2]=Table2.ID AND userId=@userId
      )

The question is based around the nested contents i.e.

SELECT DISTINCT ID FROM [Table3]
WHERE [column2]=Table2.ID AND userId=@userId

Is there anyway for Table2.id to come from the "SELECT * FROM Table2" query listed above it?

I hope this makes sense?

Thanks
Webbo

ASKER CERTIFIED SOLUTION
Avatar of lof
lof
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial