The SQLite WHERE condition is used in a query consisting of one or more tables to return the records that meet the conditions immediately after it.


The SQLite WHERE syntax is as follows:

SELECT * FROM table_name WHERE condition;


For example, to return the students with the first name Charlotte from students table, you would use the following SQL query:

SELECT * FROM students WHERE first_name = 'Charlotte';

After using the WHERE clause, it can be followed by multiple conditions like AND, OR. The WHERE condition is always written before AND, OR.

The example below returns records with customers who had at least one order and who are from New York City. For this, the WHERE condition was used to join the customers and orders table, then the AND condition was used to select only the customers from the city of New York.

SELECT c.id, c.name, o.order_id
FROM customers c, orders o
WHERE c.id=o.customer_id
AND c.city='New York';