hi ken, you shoudl be able to do this subquery:
select id from books where id not in (select subj_code from subjects); to get all the books that dont' have subject codes that is, if subj_code and book_id are linked... hth -- Susan Teague Rector Web Applications Manager VCU Libraries: Library Information Systems 804.827.3554 | [EMAIL PROTECTED] Ken Irwin wrote:
Hi folks, I'm trying to put together a MySQL query to do something I don't know how to do: get a list of materials that DON'T show up in a relational table. For example, 3 tables: 1) lib.books : lots of bib data including book_id 2) lib.subjects: subj_code, selector, subject_name 3) relational: lists book_id & subj_code I want to generate a list of books that are in lib.books that doesn't have any subjects assigned to it. I could do this with 2 queries, but it gets unwieldy: get a list of distinct book_ids and AND/NOT them all together like: SELECT * FROM books WHERE book_id != '4' and book_id != '7'... That works on really small sets, but I don't want to go that route. Is there a savvy way to structure this MySQL query. I don't even know the language to use to look for this information. Thanks for any help you can provide! Ken -- Ken Irwin Reference Librarian Thomas Library, Wittenberg University
