SQL, a table (thesau) with terms that may or may not be in use in several other tables. The other tables point to the id in thesau. I want to find out which terms are NOT in use, i.e. which terms are not referred to by any other table. Simplified:
table: thesau id term 1 painting 2 sari 4 oil 5 silk 8 gouache table: object_type id 1 (-> painting) 7 (-> ... ) table: material_type: id 2 (-> silk) 4 (-> oil) in collection, object_type 1 refers to thesau 1 = painting, and so on. Now, I can find thesau terms not in use in one single table, like so:
select distinct thesau.id, thesau.term from thesau_term where thesau_term.id not in (select object_type.id from object_type) This works. I want to expand the same query to other tables, in one query if possible. In pseudo-code:
select distinct id, term from thesau_term where thesau_term.id not in ((select object_type.id from object_type) or (select material_type.id from material_type)) This doesn't work. What am I missing?