MySQL Joins Exercises: Find the addresses of all the departments
MySQL Joins: Exercise-1 with Solution
Write a query to find the addresses (location_id, street_address, city, state_province, country_name) of all the departments.
Sample table: locations
Sample table: countries
Code:
SELECT location_id, street_address, city, state_province, country_name
FROM locations
NATURAL JOIN countries;
Relational Algebra Expression:
Relational Algebra Tree:
Sample Output:
location_id street_address city state_province country_name 1000 1297 Via Cola di Rie Roma Italy 1100 93091 Calle della Testa Venice Italy 1200 2017 Shinjuku-ku Tokyo Tokyo Prefecture Japan 1300 9450 Kamiya-cho Hiroshima Japan 1400 2014 Jabberwocky Rd Southlake Texas United States of America 1500 2011 Interiors Blvd South San Francisco California United States of America 1600 2007 Zagora St South Brunswick New Jersey United States of America 1700 2004 Charade Rd Seattle Washington United States of America 1800 147 Spadina Ave Toronto Ontario Canada 1900 6092 Boxwood St Whitehorse Yukon Canada 2000 40-5-12 Laogianggen Beijing China 2100 1298 Vileparle (E) Bombay Maharashtra India 2200 12-98 Victoria Street Sydney New South Wales Australia 2300 198 Clementi North Singapore Singapore 2400 8204 Arthur St London United Kingdom 2600 9702 Chester Road Stretford Manchester United Kingdom 2700 Schwanthalerstr. 7031 Munich Bavaria Germany 2800 Rua Frei Caneca 1360 Sao Paulo Sao Paulo Brazil 2900 20 Rue des Corps-Saints Geneva Geneve Switzerland 3000 Murtenstrasse 921 Bern BE Switzerland 3100 Pieter Breughelstraat 837 Utrecht Utrecht Netherlands
MySQL Code Editor:
Structure of 'hr' database :
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous:MySQL Joins
Next:Write a query to find the name (first_name, last name), department ID and name of all the employees.
What is the difficulty level of this exercise?
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework