What is SQL WHERE Clause?


SQL - WHERE Clause

The SQL WHERE clause is used to specify a condition while fetching the data from a single table or by joining with multiple tables. If the given condition is satisfied, then only it returns a specific value from the table. You should use the WHERE clause to filter the records and fetching only the necessary records.

Or

The SQL WHERE clause is used to filter the results and apply conditions in a SELECT, INSERT, UPDATE, or DELETE statement.

Syntax

The basic syntax of the SELECT statement with the WHERE clause is as shown below.

SELECT column1, column2, columnN
FROM table_name
WHERE [condition]

Example:

Employee_Id Emp_Name Emp_City Emp_Salary Emp_Panelty
101 Anuj Ghaziabad 25000 500
102 Tushar Lucknow 29000 1000
103 Vivek Kolkata 35000 500
104 Shivam Goa 22000 500

The following query shows the record of those employees from the above table whose Emp_Panelty is 500:

SELECT * FROM Employee_Details WHERE Emp_Panelty = 500;  

This SELECT query displays the following table in result:

Employee_Id Emp_Name Emp_City Emp_Salary Emp_Panelty
101 Anuj Ghaziabad 25000 500
103 Vivek Kolkata 35000 500
104 Shivam Goa 22000 500

Post a Comment

0 Comments

close