Showing posts with label sql where statement. Show all posts
Showing posts with label sql where statement. Show all posts

Wednesday, 23 December 2015

WHERE clause in SQL

The SQL WHERE clause is used to filter data records. It is used to fetch necessary records that fulfill a specified condition.
WHERE clause syntax:
SELECT column1, column2,…columnN FROM table_name WHERE column_name [operator value]
Example:
Select CustomerId, Cname from BANK where Salary >=7000
Select * from Bank where Salary >=7000
Select CustomerId, Cname from BANK where City=’Mumbai’
Query 1 retrieves all the rows for Customerid and Cname columns which satisfies the condition employee having Salary greater than or equal to 7000.
Query 2 retrieves all the rows for all the columns available in table which satisfies the condition employee having Salary greater than or equal to 7000.
Query 3 retrieves all the rows for Customerid and Cname columns which are from city Mumbai.
Note: The character or string field value need to be quoted in single quote.
We can use the =, <>, >, =>, <, <=, IN, BETWEEN, LIKE operators in WHERE clause.