Sobes.tech
Junior

What is the WHERE operator in SQL?

sobes.tech AI

Answer from AI

The WHERE operator in SQL is used to filter records in a table. It retrieves only those rows that meet the specified condition.

Syntax:

SELECT column1, column2, ...
FROM table_name
WHERE condition;
  • condition - the condition that determines which records will be selected.

Examples of conditions:

  • Comparison (=, !=, >, <, >=, <=)
  • Logical operators (AND, OR, NOT)
  • Functions BETWEEN, LIKE, IN, IS NULL, IS NOT NULL

Example usage:

SELECT *
FROM customers
WHERE city = 'New York';

This query will select all columns from the customers table only for those records where the value in the city column is 'New York'.