[英]mysql Left join, mysql does an inner join?
I want to do a left join but mysql just does an inner join? 我想做一个左连接但是mysql只做一个内连接? whats wrong with my query? 我的查询有什么问题?
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 only gives those avHours who have a corresponding appointment mysql只给那些有相应约会的avhours
Thanks in advance! 提前致谢!
Because of these conditions: 由于这些条件:
and ap.calendarid = 2
and ap.appointmentdate = "2012-10-01"
you only select rows from tbl_appointment
which are not null
. 您只从tbl_appointment
中选择非null
。
If that's what you want - move them to the left join's ON
part 如果这是你想要的 - 将它们移动到左连接的ON
部分
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.