-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