Multiple SQL Tables
I am trying to pull data from a table (table A), but only want to pull the records where the same ID does not appear in a second table (table B).
Is this possible? Table A contains a unique ID field, which is referenced in Table B, so this field can be used to find entries for the same person.
I started with just pulling the info I wanted from one table:
SELECT * FROM A WHERE (availability = 'All') AND (site = '" & site & "') OR (availability = '" & availability & "') AND (site = '" & site & "')"
and now think I need an "AND B.ID field ....." But that is where I get lost!
I'm sure this is a very simple piece of code!
Thank you for any assistance you can provide!
the syntax for IS NOT IN will vary based on your DBMS. try it in various forms (IS NOT IN, NOT IN, ETC)
INSERT INTO B SELECT * FROM A WHERE A.ID (IS) NOT IN (SELECT ID FROM B)
SELECT * FROM A, B WHERE A.ID <> B.ID
(SELECT COUNT(*) FROM Table2 B WHERE B.ID = A.ID) = 0
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)