我想做一个左连接但是mysql只做一个内连接? 我的查询有什么问题?
select av.*, ap.*
from tbl_available av
left join tbl_appointment ap
on av.avHours = ap.appointmenttime
where av.avCalendarId = 2
and (ap.calendarid = 2 or ap.calendarid= null)
and (ap.appointmentdate = "2012-10-01" or ap.appointmentdate = null)
and av.avDays = DayOfweek("2012-10-01")
order by avHours
mysql只给那些有相应约会的avhours
提前致谢!
答案 0 :(得分:4)
由于这些条件:
and ap.calendarid = 2
and ap.appointmentdate = "2012-10-01"
您只选择tbl_appointment
中不是null
。
如果这就是你想要的 - 将它们移到左边连接的ON
部分