-1
我只想顯示可用的時間,以達到我想要做到這一點查詢右聯接和WHERE條件Mysql的
select * from agenda right join tbl_hora on agenda.hora_id = tbl_hora.id_hor where agenda.hora_id is null and medico_id = 40 and evento_inicio = '2012-05-05';
但是,我檢索0行,如果我請從這裏條件medico_id和evento_inicio,它顯示所有的行,我怎樣才能使查詢顯示可用的時間。
P.D.議程表是空的,因爲是ajax調用和預約。
如果我刪除agenda.hora_id爲null條件,那麼我的結果將爲0,因爲我的議程表爲空。如何才能更好地選擇不在兩個表中的結果。 – Paul
@Paul你能提供一個來自議程表和tbl_hora表格數據的樣本。因爲你所說的「因爲我的議程表是空的」意味着正確的加入而議程在左邊永遠不會帶來結果! –
我用這個查詢來解決,你怎麼看待它? 'select * from tbl_hora where not exist(在agenda.hora_id = tbl_hora.id_hor和medico_id = 40且evento_inicio ='2012-01-07'的議程中選擇hora_id;'' – Paul