1

我想做一个左连接但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

提前致谢!

4

1 回答 1

4

由于这些条件:

and ap.calendarid = 2 
and ap.appointmentdate = "2012-10-01" 

您只选择tbl_appointment不是的行null

如果这就是你想要的 - 将它们移动到左连接ON部分

于 2012-10-01T01:45:29.227 回答