我有一个简单的mysql查询,但它不能返回所有值。当我单独使用左连接表时返回所有值,但是当我添加其他表时,只有全部为“=”的表返回一个值。这是查询:
SELECT
d.flight_no , b.arrival_flight
FROM
jtl_booking_transfer_details AS b
LEFT JOIN jtl_flight_info AS d
ON (d.flight_no b.arrival_flight),
jtl_booking_master a,
jtl_hotels c,
jtl_airlines e
WHERE
a.voucher_number = b.voucher_number AND
b.hotel_id = c.hotel_id AND
e.airline_code = d.airline_code
答案 0 :(得分:2)
使用相同的语法获取所有表(更易于阅读:JOIN用于...连接表,WHERE子句用于其他谓词)
SELECT
d.flight_no , b.arrival_flight
FROM
jtl_booking_transfer_details b
LEFT JOIN jtl_flight_info d
ON d.flight_no = b.arrival_flight
LEFT JOIN jtl_booking_master a
ON a.voucher_number = b.voucher_number
LEFT JOIN jtl_hotels c
ON b.hotel_id = c.hotel_id
LEFT JOIN jtl_airlines e
ON e.airline_code = d.airline_code