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

When a method in a subclass overrides a method in superclass, it is still possible to call the overridden method using super keyword - Hacker Rank Solution.

You are given a date. You just need to write the method getDay which returns the day on that date - Hacker Rank Solution.

Java's System.out.printf function can be used to print formatted output. The purpose of this exercise is to test your understanding of formatting output using printf. To get you started, a portion of the solution is provided for you in the editor; you must format and print the input to complete the solution.