DEV Community

Manoj Kumar
Manoj Kumar

Posted on

HackerRank SQL — Querying Every Row and Column from the CITY Table

This is probably the most basic SQL query you will ever write. No filters, no conditions, no functions. Just get everything from the table and that is it.

Here is what I wrote:

SELECT *
FROM CITY;
Enter fullscreen mode Exit fullscreen mode

That is the whole thing. SELECT star means give me every column and FROM CITY tells it which table to pull from. Since there is no WHERE clause the query just returns every single row in the table without skipping anything.

I know it looks almost too simple but this is actually the query most people write first when they open a new table and want to see what is in it. It is like a first look at the data before you start filtering or doing anything fancy with it.

If you are just starting out with SQL, get comfortable with this one. Everything else you learn from here builds on top of this exact structure.

Top comments (0)