Japanese Cities’ Name

Problem Statement

Given a City table, whose fields are described as

+-------------+----------+
| Field       | Type     |
+-------------+----------+
| ID          | int(11)  |
| Name        | char(35) |
| CountryCode | char(3)  |
| District    | char(20) |
| Population  | int(11)  |
+-------------+----------+

you have to print the name of all the cities of Japan. The CountryCode for Japan is “JPN”.

Solution

  
Select Name from City where CountryCode = 'JPN';

Japanese Cities’ Detail

Problem Statement

Given a City table, whose fields are described as

+-------------+----------+
| Field       | Type     |
+-------------+----------+
| ID          | int(11)  |
| Name        | char(35) |
| CountryCode | char(3)  |
| District    | char(20) |
| Population  | int(11)  |
+-------------+----------+

you have to print all the details of all the cities of Japan. The CountryCode for Japan is “JPN”.

Solution

  
Select * from City where CountryCode = 'JPN';

Select by ID

Problem Statement

Given a City table, whose fields are described as

 

+-------------+----------+
| Field       | Type     |
+-------------+----------+
| ID          | int(11)  |
| Name        | char(35) |
| CountryCode | char(3)  |
| District    | char(20) |
| Population  | int(11)  |
+-------------+----------+

you have to print all the details of the city with ID is 1661.

Solution

  
Select * from City where ID = '1661'; 

\

Select All

Problem Statement

Given a City table, whose fields are described as

+-------------+----------+
| Field       | Type     |
+-------------+----------+
| ID          | int(11)  |
| Name        | char(35) |
| CountryCode | char(3)  |
| District    | char(20) |
| Population  | int(11)  |
+-------------+----------+

write a query that will fetch all columns for every row in the table.

Solution

  
Select * from City;