Querying with conditions

This is part of “An intro to SQL” series of posts, with content from the Enki app. If you stumbled upon this, you can start from the beginning.

Aside from columns, you might also want to restrict the number of records (rows) returned.

Introducing: the WHERE keyword! Here it is in action:

When added to a SQL SELECT statement, WHERE allows us to select rows in a table based on conditions you set.

The conditional statement that follows WHERE is evaluated for each row. If it’s evaluated as true, the row will be included in the query result.

Conditional statements can include comparison operators like:

Here’s another pokemon table:

Let’s look up all the info on the ”Caterpie” pokemon:

Which results in:

No prizes for guessing the query which gives the name and hp of all pokemon with attack greater than or equal to 30:

The results are:

Text needs to be enclosed within quotation marks (’text’), while integers¹ (and other numerical types) should not have quotes.

If you want to try these queries yourself, you can find the playground link in the Learn More section.


[1] An integer is nothing more than a whole number. For example, 1, 12345, and -999 are all integers.

Learn More

Andrei Calabangiu

Content Manager

About Enki

  • AI-powered, customized 1:1 coaching
  • Fully customized to team needs
  • Pay only for active learners and results

More articles