Forum Moderators: open
so i have a main table that has notes attached to it
I want to query the table, join on the notes table and just get a list of records that have zero notes or only have notes with a staff_id of 0 (eg system notes)
If I do a regulat join i get all the records that have notes with only system notes but it omits the records with zero notes
like so:
SELECT r.rfq_id FROM `rfq` r
inner JOIN rfq_admin_notes n on r.rfq_id = n.rfq_id
where n.staff_id <= 0
group by n.rfq_id
- this gives me a list of all rfqs that only have system notes, but i also need the ones that have zero notes, so i tried an old join like so:
SELECT r.rfq_id FROM `rfq` r, rfq_admin_notes n
where n.staff_id = 0
group by r.rfq_id
- this gives me all the records even ones with notes that have staff_ids above 0, I tried :
SELECT r.rfq_id FROM `rfq` r, rfq_admin_notes n
where (n.staff_id = 0 OR n.staff_id = '')
group by r.rfq_id
but it gives the same results - is there a way to do this so i can just get the records that have a note with a staff_id of 0 OR no note in the second table?
this is mysql3 so i cant do really fancy joins and selects