Query all attributes of every Japanese city in the CITY table. The COUNTRYCODE for Japan is JPN.

 The CITY table is described as follows:


THEORY:

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:

IDNameCountryCodeDistrict    Population
1    Tokyo                JPNTokyo    9000000
2    Osaka       JPNOsaka    2700000
3    New York       USANew York    8000000

๐Ÿ› ️ Key Concepts

  • SELECT *: This is used to select all columns from a table.

  • WHERE clause: Used to filter records based on a specified condition.

  • = operator: Used for exact matching.

๐Ÿ” SQL Query Format

SELECT * FROM CITY WHERE COUNTRYCODE = 'JPN';

๐Ÿง  What This Does:

  • SELECT *: Gets all columns (e.g., ID, Name, District, Population, etc.).

  • FROM CITY: Tells SQL to pull data from the CITY table.

  • WHERE COUNTRYCODE = 'JPN': Restricts the output to only Japanese cities.


SOLUTION:

SELECT * FROM CITY WHERE COUNTRYCODE='JPN';

Popular posts from this blog

In this problem, you will practice your knowledge on interfaces - Hacker Rank Solution.