Query all attributes of every Japanese city in the CITY table. The COUNTRYCODE for Japan is JPN.
The CITY table is described as follows:
When working with relational databases, we often need to extract specific data based on certain conditions. In this case, we're working with a table named CITY, which contains data about various cities around the world.
✅ Objective
Retrieve all attributes (columns) of every city in Japan, where the COUNTRYCODE is 'JPN'.
๐ Understanding the Table Structure
The CITY table might typically look like this:
| ID | Name | CountryCode | District | Population |
|---|---|---|---|---|
| 1 | Tokyo | JPN | Tokyo | 9000000 |
| 2 | Osaka | JPN | Osaka | 2700000 |
| 3 | New York | USA | New York | 8000000 |
๐ ️ Key Concepts
-
SELECT *: This is used to select all columns from a table. -
WHEREclause: Used to filter records based on a specified condition. -
=operator: Used for exact matching.
๐ SQL Query Format
๐ง What This Does:
-
SELECT *: Gets all columns (e.g., ID, Name, District, Population, etc.). -
FROM CITY: Tells SQL to pull data from theCITYtable. -
WHERE COUNTRYCODE = 'JPN': Restricts the output to only Japanese cities.
