所以,我有这个 sql 查询:
select
o.id,
o.name,
d.name,
w.day,
o.suspended
from resource o
left join resource d on d.vehicle_ID = o.ID
left join week_days_availability_to_resource aw on d.ID=aw.resource_ID
left join week_days_availability w on aw.calendar_ID=w.ID
where o.IS_DELETED <> true
and (d.IS_DELETED is null or d.IS_DELETED <> true)
and o.marketId = 98
and (w.day = 3 or w.day is null)
and (o.suspended <> true or o.id in (-1))
它返回我需要的所有行 - 除了一个。表resource o
中有行与resource d
连接,然后与 连接week_days_availability_to_resource
(此表中有一些行与resource_ID
等于d.ID
)。问题是没有等于三的行,所以它什么也不返回week_days_availability
。day
但我希望用字段值mysql
返回这一行- 因为我认为这实际上是这样做的。好像我错了。
有任何想法吗?NULL
day
left join