0

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 query to return all the cities from cities even if they dont have a city_date associated with it?

1 Answer 1

4

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;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.