Introduction
In this project, you will learn how to retrieve city names and their corresponding country names from a MySQL database using an equi-join query. This project will help you understand the basics of SQL queries and how to work with relational databases.
๐ Preview
MariaDB [world]> SOURCE /home/labex/project/getCountryName.sql;
+----------------+-------------+
| CityName | CountryName |
+----------------+-------------+
| Oranjestad | Aruba |
| Kabul | Afghanistan |
| Qandahar | Afghanistan |
| Herat | Afghanistan |
| Mazar-e-Sharif | Afghanistan |
| Luanda | Angola |
| Huambo | Angola |
| Lobito | Angola |
| Benguela | Angola |
| Namibe | Angola |
+----------------+-------------+
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 a SQL file into a MySQL database
- How to write an equi-join query to retrieve data from multiple tables
- How to simplify table names and use aliases in SQL queries
- How to run a SQL script in MySQL
๐ Achievements
After completing this project, you will be able to:
- Understand the basic structure and syntax of SQL queries
- Perform equi-join operations to retrieve data from multiple tables
- Simplify table names and use aliases to make your SQL queries more readable
- Import and manage data in a MySQL database
- Run SQL scripts to execute complex queries
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-301298{{"`City Names and Respective Countries`"}}
mysql/database -.-> lab-301298{{"`City Names and Respective Countries`"}}
sql/select -.-> lab-301298{{"`City Names and Respective Countries`"}}
sql/where -.-> lab-301298{{"`City Names and Respective Countries`"}}
sql/join -.-> lab-301298{{"`City Names and Respective Countries`"}}
mysql/select -.-> lab-301298{{"`City Names and Respective Countries`"}}
mysql/use_database -.-> lab-301298{{"`City Names and Respective Countries`"}}
sql/insert -.-> lab-301298{{"`City Names and Respective Countries`"}}
sql/create_table -.-> lab-301298{{"`City Names and Respective Countries`"}}
end