我有这个查询
SELECT cities.city, city_date.date_avail
FROM cities, city_date
WHERE city_date.city_id = cities.id;
但我想查询从城市返回所有城市,即使他们没有与之关联的city_date?
答案 0 :(得分:4)
参见OUTER JOINS;)(RIGHT / LEFT / FULL)
SELECT cities.city, city_date.date_avail
FROM cities
LEFT OUTER JOIN city_date ON city_date.city_id = cities.id;