d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Where Do I Post This
Add Reply New Topic New Poll
Member
Posts: 1,144
Joined: Jul 25 2012
Gold: 0.00
Sep 16 2012 11:17am
Where should I post a question about SQL??

Just having trouble understanding how to use a natural join in postgreSQL 9.0.....


I have


SELECT Country.Name, City.Name, City.Population FROM Country, City WHERE Country.Population < 5000;

I just don't understand how to rewrite this using joins?
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Sep 16 2012 11:23am
this place is fine.

your query is bad since there's nothing in the where clause to connect the country and city.

SELECT Country.Name, City.Name, City.Population FROM Country co
inner join City ci
on ci.countryid=co.countryid
WHERE co.Population < 5000;
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll