MySQL Forums
Forum List  »  Newbie

Re: Sakila giving some strange results
Posted by: Saleem Hasan
Date: April 06, 2015 10:46PM

Barry,

Thank you very much for taking a look at my queries.

Saleem

1. select city_id, city, country from city inner join country on city.country_id = country.country_id where city = 'london';

Returned 2 records
313 London Canada
312 London United Kingdom

2. Also ran a simpler query
select city_id, city from city where city = 'london';

Returned 2 records
312 London
313 London

3. select city.city_id, city, address.address, address.district from city inner join address on
city.city_id = address.city_id where city = 'london';

Returned 2 records
312 London 1497 Yuzhou Drive England
312 London 548 Uruapan Street Ontario

4. To query 3, I added an inner join with table Country and added country in select

select city.city_id, city, address.address, address.district, country from city inner join address on
city.city_id = address.city_id inner join country.country_id = city.country_id where city = 'london';

312 London 1497 Yuzhou Drive England United Kingdom
312 London 548 Uruapan Street Ontario United Kingdom

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.