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.

Arrastra en el orden correspondiente.


Arrastra las opciones:

SELECT
age < 25
WHERE
FROM
clients
*

Completa el código:

______
______
______
______
______
______

Interactive Test 2: Fill in the Blanks

Rellena los huecos en cada casilla.


SELECT  FROM  WHERE ;

Practical Exercise:


Statement:

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


Datos de Ejemplo

idnameage
1 Juan 25
2 Ana 30
3 Luis 22
4 Marta 35

* Escribe tu consulta SQL y ejecuta para ver los resultados.

Resultados:

No hay resultados disponibles.


What is the function of the WHERE clause in SQL?