Introduction
In this project, you will learn how to query and retrieve information from a MySQL database. Specifically, you will learn how to access the MySQL database, import a pre-existing database, and execute a SQL query to retrieve information about cities based on their IDs.
👀 Preview
MariaDB [world]> SOURCE /home/labex/project/getTen.sql;
+----+----------------+-------------+---------------+------------+
| ID | Name | CountryCode | District | Population |
+----+----------------+-------------+---------------+------------+
| 1 | Kabul | AFG | Kabol | 1780000 |
| 2 | Qandahar | AFG | Qandahar | 237500 |
| 3 | Herat | AFG | Herat | 186800 |
| 4 | Mazar-e-Sharif | AFG | Balkh | 127800 |
| 5 | Amsterdam | NLD | Noord-Holland | 731200 |
| 6 | Rotterdam | NLD | Zuid-Holland | 593321 |
| 7 | Haag | NLD | Zuid-Holland | 440900 |
| 8 | Utrecht | NLD | Utrecht | 234323 |
| 9 | Eindhoven | NLD | Noord-Brabant | 201843 |
| 10 | Tilburg | NLD | Noord-Brabant | 193238 |
+----+----------------+-------------+---------------+------------+
10 rows in set (0.000 sec)
🎯 Tasks
In this project, you will learn:
- How to access MySQL using the
sudo
command without a password - How to import a pre-existing SQL database into MySQL
- How to write and execute a SQL query to retrieve city information based on ID
🏆 Achievements
After completing this project, you will be able to:
- Understand how to access and work with a MySQL database
- Write SQL queries to retrieve specific data from a database
- Apply your knowledge of SQL to solve real-world data retrieval problems