$numQuery1 = "
SELECT d.*
, r.*
, AVG(c.on_time)+AVG(c.friendly)+AVG(c.language_skills)+AVG(c.professional) ranking
FROM comment c
LEFT
JOIN driver d
ON d.userid = c.driver_id
LEFT
JOIN driver_rental r
ON r.email = d.email
WHERE
(
$driver_rental IS NOT NULL
AND $driver_rental != ''
AND car_type_1 >= $_SESSION[car_type_1]
)
OR car_type_2>=$_SESSION[car_type_1]);
";
如果評語表有沒有driver_id記錄,結果是空的,我可以忽略評語表,但在select語句不能沒有它?MySQL的加入三表,如果一個表中沒有記錄
推測car_type_1來自司機租賃表? (如果你在查詢中明確指出這種情況,那麼這很有用) – Strawberry