MySQL query, select what hasn't been selected.
Posted: Fri Aug 28, 2009 10:11 am
I think this is the right board to post this in. Kinda new here. Anyways;
Basically i want to select everything in a table which isn't in another one...
ok, that made more sense in my head.
I have 3 tables, 'days' 'duties' and 'duty_days'
duty_days has duty_id and day_id fields (from the other two tables)
what I want to do is select all the duties which are on the same day_id, then the rest of the duties.
hope this is making sense so far...
currently I have
I then want to select all the `titles` from `duties` which weren't in the orginal query.
Any ideas how to do this?
thanks
oh yer `days` just has `name` and `day_id`, eg
monday 1
tuesday 2
wednesday 3
...
Basically i want to select everything in a table which isn't in another one...
ok, that made more sense in my head.
I have 3 tables, 'days' 'duties' and 'duty_days'
duty_days has duty_id and day_id fields (from the other two tables)
what I want to do is select all the duties which are on the same day_id, then the rest of the duties.
hope this is making sense so far...
currently I have
Code: Select all
SELECT `title`, `duties`.`duty_id` FROM `duties`, `duty_days` WHERE `duty_days`.`day_id` = "' . $d . '" AND `duty_days`.`duty_id` = `duties`.`duty_id` ORDER BY `duties`.`start_time` ASCAny ideas how to do this?
thanks
oh yer `days` just has `name` and `day_id`, eg
monday 1
tuesday 2
wednesday 3
...