Filters and conditions with WHERE


  In SQL, the WHERE clause is used to filter records and determine which rows will be returned in query results.


Using the WHERE clause


The syntax for using WHERE is as follows:
SELECT [columns] FROM [table] WHERE [condition];


Filter Examples


  • Get all clients under 25 years old: SELECT * FROM clients WHERE age < 25;
  • Get products with a price greater than 100: SELECT * FROM products WHERE price > 100;


Exercises



Interactive Test 1: Drag and Drop.

Drag in the corresponding order.


Drag the options:

SELECT
age < 25
WHERE
FROM
clients
*

Completa el código:

______
______
______
______
______
______

Interactive Test 2: Fill in the Blanks

Fill the Blanks.


SELECT  FROM  WHERE ;

Practical Exercise:


Statement:

  Write the necessary Query (consultation) to display all clients in a table who are under 25 years old.


Example Data

idnameage
1John25
2Anna30
3Kevin22
4Angela35

* Write your SQL query and execute to see results.

Resultados:

No results available.


What is the function of the WHERE clause in SQL?