DEV Community

Cover image for HackerRank SQL Preparation: Select by ID(MySQL)
Christian Paez
Christian Paez

Posted on

3

HackerRank SQL Preparation: Select by ID(MySQL)

Problem Statement:
Query all columns for a city in the CITY table with the ID 1661.


Link: HackerRank - Select by ID

Solution:

SELECT * FROM CITY WHERE ID = 1661;
Enter fullscreen mode Exit fullscreen mode

Explanation:

  • SELECT *: The asterisk (*) is a wildcard character in SQL that means "all columns." This part of the query specifies that you want to retrieve all columns from the table.
  • FROM CITY: Indicates that you are selecting data from the CITY table.
  • WHERE ID = 1661: This condition filters the rows to include only the city with the specific ID of 1661.

This query will return all the columns for the row in the CITY table where the ID is 1661. It's useful when you need to retrieve all details about a specific city identified by its unique ID.

By running this query, you can see all the attributes (such as city name, country code, population, etc.) for the city that has the ID of 1661.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more