SQL WHERE

Learn how to use SQL WHERE clause for a conditional result. Find out how to filter the result using SQL WHERE clause with select, update and delete query.

The WHERE clause is data manipulation language used to manipulate the record based on the specified condition. It can be useful when you need a rule-based which you will get the accurate result from the table.

You can use it for SELECT, UPDATE AND DELETE statements. However, you cannot use it with the INSERT statement to insert the data based on conditions.

How to Use SQL WHERE Clause and Filter Result Based on Condition

The syntax to use the SQL WHERE clause with other statements given below. You have to use the condition at the end of each statement. However, it’s optional to use the condition with the statements.

Syntax1: WHERE Clause with SELECT Statement

The above syntax contains the SELECT statement with the column and the table name. In addition to this, you can specify the condition through which you can filter the result as per your requirement.

Syntax2: WHERE Clause with UPDATE Statement

You can update the value of a column with the above syntax. Specify the condition to update the exact value you want to update. If you do not specify the condition with the above syntax, the query will update all the values in the specified column.

Syntax3: WHERE Clause with DELETE Statement

Delete the exact date from the table using the specified condition. The above syntax deletes the rows from the table using the specified condition to delete the exactly required rows. If you do not specify the condition, the above syntax if not use with WHERE condition will delete all the data of a table.

Parameter Descriptions

Sr.No Parameter Name Description
1 column_name Enter the column names for which you want to apply the WHERE condition and filter the exact rows. You can also use the symbol (*) to apply the condition to all the columns all the columns of a table. In addition to this, you can specify multiple columns with comma(,) separation.
2 tablename Specify the table name to which you want to apply the condition.
3 condition Specify the condition with the operator, columns, and values to get the exact rows.

You must also learn.

Reference