-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