How to use SQL WHERE Condition with Example?
A SQL WHERE Condition statement only affect rows that meet mentioned criteria and the criteria are expressed in the form of predicates. WHERE clauses are not mandatory clauses of SQL but can be used to limit the number of rows affected by a structured query language (SQL), or returned by a query. the main purpose of SQL WHERE clause is used to extract only those Record from a SQL statement, like as INSERT, SELECT, DELETE or UPDATE, statement.
The SQL WHERE Condition

- SQL WHERE Clause with SELECT query.
SELECT column-names FROM table-name WHERE condition
- WHERE Clause with an UPDATE query.
UPDATE table-name SET column-name = value WHERE condition
- SQL WHERE Condition with a DELETE query
DELETE table-name WHERE condition
Example for SQL WHERE Clause
SELECT Id, FirstName, LastName, City, Gender FROM Employee WHERE City = 'New Delhi'
Result
| Id | FirstName | LastName | City | Gender |
|---|---|---|---|---|
| 1 | Mark | Otto | New Delhi | Male |
| 2 | John | Petter | New Delhi | Male |
| Employee |
|---|
| Id |
| FirstName |
| LastName |
| City |
| Gender |
Example for SQL WHERE Clause with an Updates Statement.
UPDATE Supplier SET City = 'New Delhi' WHERE Name = 'John'
Result: update below given line
2JohnPetterNew DelhiMale
| Id | FirstName | LastName | City | Gender |
|---|
Example for SQL WHERE Clause with DELETE Statement
>
DELETE FROM Product WHERE UnitPrice > 50
| PRODUCT |
|---|
| Id |
| ProductName |
| SupplierId |
| UnitPrice |
| IsDiscontinued |
| Package |
Resource
w3school