SQL where clause with query example – Where clause in SQL is used to fetch records on the basis of some condition.
For example,
List the books whose cost is greater than 400.
Delete the book whose price is less than 100.
Update the book value price where the price is equal to 500 etc.
POINTS
- WHERE condition is used to filter the data from the table when using SELECT statement, Update statement and DELETE statement.
- WHERE can be used with single or multiple conditions.
SQL WHERE Syntax
SELECT [column_1],…. FROM [Table_name]
WHERE [CONDITION];
SQL WHERE Example
Find the titles where price greater than 400 from books table.
Query:
SELECT TITLE FROM BOOKS WHERE PRICE > 400;
Output:
TITLE |
---|
MOON CALLED |
TWILIGHT |
PRIDE AND PREJUDICE |