Introduction
In this project, you will learn how to execute an equal join query on the city
, country
, and countrylanguage
tables in MySQL. The goal is to retrieve the city name, corresponding country name, and language from these tables.
๐ Preview
MariaDB [world]> SOURCE /home/labex/project/getCountryNameAndLanguage.sql;
+----------------+-------------+------------+
| CityName | CountryName | Language |
+----------------+-------------+------------+
| Oranjestad | Aruba | Dutch |
| Oranjestad | Aruba | English |
| Oranjestad | Aruba | Papiamento |
| Oranjestad | Aruba | Spanish |
| Kabul | Afghanistan | Balochi |
| Qandahar | Afghanistan | Balochi |
| Herat | Afghanistan | Balochi |
| Mazar-e-Sharif | Afghanistan | Balochi |
| Kabul | Afghanistan | Dari |
| Qandahar | Afghanistan | Dari |
+----------------+-------------+------------+
10 rows in set (0.001 sec)
๐ฏ Tasks
In this project, you will learn:
- How to access MySQL using the
sudo
command without a password
- How to import data from the
world.sql
script into MySQL
- How to write an equal join query to retrieve the desired information from the tables
- How to limit the query results to the first 10 rows
๐ Achievements
After completing this project, you will be able to:
- Understand the concept of SQL joins and how to use them effectively
- Retrieve data from multiple tables in a relational database
- Apply SQL queries to filter and limit the results as needed
- Gain practical experience in working with MySQL databases
Skills Graph
%%%%{init: {'theme':'neutral'}}%%%%
flowchart RL
mysql(("`MySQL`")) -.-> mysql/BasicKeywordsandStatementsGroup(["`Basic Keywords and Statements`"])
mysql(("`MySQL`")) -.-> mysql/DatabaseFunctionsandDataTypesGroup(["`Database Functions and Data Types`"])
sql(("`SQL`")) -.-> sql/BasicSQLCommandsGroup(["`Basic SQL Commands`"])
sql(("`SQL`")) -.-> sql/DataManipulationandQueryingGroup(["`Data Manipulation and Querying`"])
sql(("`SQL`")) -.-> sql/AdvancedDataOperationsGroup(["`Advanced Data Operations`"])
mysql/BasicKeywordsandStatementsGroup -.-> mysql/source("`External Code Execution`")
mysql/DatabaseFunctionsandDataTypesGroup -.-> mysql/database("`DB Function - Info Retrieval`")
sql/BasicSQLCommandsGroup -.-> sql/select("`SELECT statements`")
sql/DataManipulationandQueryingGroup -.-> sql/where("`WHERE clause`")
sql/AdvancedDataOperationsGroup -.-> sql/join("`JOIN operations`")
mysql/BasicKeywordsandStatementsGroup -.-> mysql/select("`Data Retrieval`")
mysql/BasicKeywordsandStatementsGroup -.-> mysql/use_database("`Database Selection`")
sql/BasicSQLCommandsGroup -.-> sql/insert("`INSERT INTO statements`")
sql/BasicSQLCommandsGroup -.-> sql/create_table("`CREATE TABLE statements`")
subgraph Lab Skills
mysql/source -.-> lab-301382{{"`Query City Names with Country`"}}
mysql/database -.-> lab-301382{{"`Query City Names with Country`"}}
sql/select -.-> lab-301382{{"`Query City Names with Country`"}}
sql/where -.-> lab-301382{{"`Query City Names with Country`"}}
sql/join -.-> lab-301382{{"`Query City Names with Country`"}}
mysql/select -.-> lab-301382{{"`Query City Names with Country`"}}
mysql/use_database -.-> lab-301382{{"`Query City Names with Country`"}}
sql/insert -.-> lab-301382{{"`Query City Names with Country`"}}
sql/create_table -.-> lab-301382{{"`Query City Names with Country`"}}
end