I can't seem to wrap my head around this, please see if you can help me out. I have 2 tables. One with some basic info but they are structured as follows.
info table: IDNum(PK) LName FName Title Deladd City State Zip
codes table: IDNum (used only so that there could be a primary key :-/ ) info_IDNum(fk) code
Won't MySql allow you to make the combination of info_IDNum and code a primary key?
The code column in the codes table can contain multiple codes for each
info_IDNum. I want to make a query where it shows all the info_IDNum results
that DON'T have an entry in the codes.code = 13. Where I am having trouble is
that there are multiple codes for any given IDNum.
Anyway, since MySql doesn't support subqueries, you need to use a left join, which returns rows whether or not a match is found, and make use of the fact that if no match is found the data will be NULL.
SELECT * FROM info i LEFT JOIN codes c ON i.IDNum = c.info_IDNum WHERE c.code IS NULL;
Bruce Feist
--------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php