-1
为什么此查询未考虑“c.max_no_people < = $ max_guests”的Where子句?MySQL Double Join with Multiple Where Clauses
SELECT DISTINCT a.id, b.post_id, c.max_no_people
FROM wp_dopbsp_reservations a
INNER JOIN wp_dopbsp_calendars b
ON (b.id = a.calendar_id)
INNER JOIN wp_dopbsp_settings c
ON (b.id = c.calendar_id)
WHERE (a.check_out >= \"$check_in\"
AND a.check_in < \"$check_out\"
OR a.check_out <= \"$check_in\"
AND a.check_in > \"$check_out\")
AND (c.max_no_people <= $max_guests)
AND (a.status = 'approved')
在此先感谢。
我的坏。现在编辑它:) – Torrezzzz
感谢您的答案!奇怪的是,我仍然没有得到预期的结果。即使$ max_guests小于或等于DB中存储的值,它也会返回保留。 – user960487