Hi, i have a simple query but for some reason it's not working.
Let me get to the point.
2 tables - table1(id,txtfield1) table2(userid, idfield)
idfield contains id so foreign key (although hasnt been set up as that yet)
Aim: select all fields from table1 where table2 doesn't contain them.
e.g if table 1 had, 5 rows containing:
1 - test
2 - test2
3 - test3
4 - test4
5 - test6
and table 2 had:
1 - 4
2 - 5
Then when the query ran, it would only pick up 1 - test, 2 - test2, 3 - test3.
Any ideas. I have tried but with no luck:
Let me get to the point.
2 tables - table1(id,txtfield1) table2(userid, idfield)
idfield contains id so foreign key (although hasnt been set up as that yet)
Aim: select all fields from table1 where table2 doesn't contain them.
e.g if table 1 had, 5 rows containing:
1 - test
2 - test2
3 - test3
4 - test4
5 - test6
and table 2 had:
1 - 4
2 - 5
Then when the query ran, it would only pick up 1 - test, 2 - test2, 3 - test3.
Any ideas. I have tried but with no luck:
Code:
SELECT [ID], [txtfield1] FROM table1 WHERE NOT EXISTS (SELECT [idfield] FROM table2)