[HackerRank MySQL] SELECT, WHERE 문제풀기 (Basic)

2021. 1. 5. 19:15Today I Learned.../MySQL

Revising the Select Query I

Query all columns for all American cities in the CITY table with populations larger than 100000. The CountryCode for America is USA. 

The CITY table is described as follows:

select *
from city
where population > 100000 and countrycode = 'usa'

Revising the Select Query II

Query the NAME field for all American cities in the CITY table with populations larger than 120000. The CountryCode for America is USA.

select name
from city
where population > 120000 and countrycode = 'usa'

Select All

Query all columns (attributes) for every row in the CITY table.

select *
from city

Select By ID

Query all columns for a city in CITY with the ID 1661.

select *
from city
where id = 1661

Japanese Cities' Attributes

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

select *
from city
where countrycode = 'jpn'

Japanese Cities' Names

Query the names of all the Japanese cities in the CITY table. The COUNTRYCODE for Japan is JPN.

select name
from city
where countrycode = 'jpn'

문제 출처: 해커랭크