Hello! I have to display Badgenumbers who have no Veterinary Skills from this table: RANGER-EXPERT BADGENUM WOODCRAFT SKILL B007 First Aid B007 Trailcraft B007 Birdcalls B007 Veterinary B006 First Aid B006 Veterinary B006 Firemaking B023 Trailcraft B023 Wild Food Finding B045 Veterinary BADGENUM and WOODCRAFT SKILL is a composite primary key. The problem is that I have written this query: SELECT BADGENUM -> FROM `RANGER-EXPERT` -> WHERE `WOODCRAFT SKILL`!='Veterinary'; +----------+ | BADGENUM | +----------+ | B006 | | B006 | | B007 | | B007 | | B007 | | B023 | | B023 | +----------+ But B006 and B007 have Veterinary Skills, according to the table. What should I do to solve the problem? Thank you very much for your help!
The easiest way to do it would be with a sub-query... where you are first getting the BADGENUMs to omit with the subquery, and then using those results to get everything *without* those BADGENUMs. I believe this should work for you: SELECT DISTINCT BADGENUM FROM `RANGER-EXPERT` WHERE BADGENUM NOT IN ( SELECT BADGENUM FROM `RANGER-EXPERT` WHERE `WOODCRAFT SKILL` = 'Veterinary' ); Code (SQL): That will return badge numbers that don't include a record Veterinary. The "DISTINCT" part makes it return just unique ones. Like that will return one B023, not 2 B023 records.