Skip to main content

Command Palette

Search for a command to run...

HackerRank: Select By ID

Published
1 min read

Question and Answer:

Key Points:

What the Query Does

  • Fetches all columns for the city with ID = 1661

Key Conditions Used

  • WHERE ID = 1661 ensures we only retrieve the specific city requested

Why It Works

  • SELECT * returns all available fields (ID, NAME, COUNTRYCODE, DISTRICT, POPULATION)

  • ID uniquely identifies a city, so the result will be one row (or none if not found)

Output

  • One row containing the full details of city with ID 1661