Code: Select all
SELECT DISTINCT gop_id, gop_option
FROM tbl_gradeoptions
LEFT JOIN tbl_customgrades ON gop_id = cgr_optionid
WHERE ( cgr_classid = '33' )gop_id (primary key)
gop_option (some text)
And tbl_customgrades has:
cgr_id (primary key)
cgr_classid (foreign key)
cgr_optionid (foreign key to gop_id)
cgr_percentage (some more text)
Now I want to get all records from tbl_gradeoptions that don't have records with matching keys in tbl_customgrades (gop_id and cgr_optionid) and also where the classid is 33.
Now my query gives me the opposite of what I want, so I know I am sorta on my way there. Help?
Example:
tbl_gradeoptions
gop_id - gop_option
1 - Apple
2 - Pear
3 - Grape
4 - Durian
tbl_customgrades
cgr_id - cgr_classid - cgr_optionid - cgr_percent
1 - 33 - 3 - nine
2 - 32 - 2 - eight
3 - 52 - 4 - five
4 - 33 - 4 - two
So selecting from the first table, i would want to get Apple & pear only.