SQL Exercise: City where the opening match of EURO cup 2016 played
SQL soccer Database: Joins Exercise-12 with Solution
12. From the following table, write a SQL query to find the city where the opening match of EURO cup 2016 took place. Return venue name, city.
Sample table: soccer_venue
Sample table: soccer_city
Sample table: match_mast
SELECT a.venue_name, b.city FROM soccer_venue a JOIN soccer_city b ON a.city_id=b.city_id JOIN match_mast c ON a.venue_id=c.venue_id WHERE match_no=1;
venue_name | city -----------------+------------- Stade de France | Saint-Denis (1 row)
The said query in SQL that selects the name of the venue where match number 1 is played, and the city in which the venue is located from the tables soccer_venue, soccer_city, and match_mast.
The JOIN keyword is used to join the soccer_venue with soccer_city on their city_id columns, and then join the resulting table with match_mast on their venue_id columns.
The WHERE keyword filters data for the match with match number 1.
Relational Algebra Expression:
Relational Algebra Tree:
Sample Database: soccer
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous SQL Exercise: Referee who assisted in the final match.
Next SQL Exercise: Stadium hosted the final match of EURO cup 2016.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
SQL: Tips of the Day
What is the best way to paginate results in SQL Server?
SELECT * FROM ( SELECT ROW_NUMBER() OVER ( ORDER BY OrderDate ) AS RowNum, * FROM Orders WHERE OrderDate >= '1980-01-01' ) AS RowConstrainedResult WHERE RowNum >= 1 AND RowNum < 20 ORDER BY RowNum
Database: SQL Server
- Weekly Trends
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
- Python Tutorial
- Python Array Exercises
- SQL Cross Join
- C# Sharp Array Exercises
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook