开发者

mysql joining empty rows?

i have this query

SELECT cities.city, city_date.date_avail 
FROM cities, city_date 
WHERE city_date.city_id = cities.id;

but i would like the q开发者_运维百科uery to return all the cities from cities even if they dont have a city_date associated with it?


see 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;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜