SQL Where clause

SQL "Where" clause is used to filter the data from a database table object. This where is used with SELECT, INSERT, UPDATE, or DELETE statement. Below example will explain the use of Where clause in details.SQL Where clause syntax

SELECT column_name1,
column_name2
FROM table_name
WHERE column_name1 operator_name value

In above example "operator_name" is the operator used for fetching the value;it could be any operator. The "value" is the value of columns on which records would be filtered. This value field must have the same data type as filtering column. So in this syntax;column_name1 and value must have same datatype so that SQL can compare it.

Example

SELECT NationalIDNumber,
OrganizationNode,
OrganizationLevel,
JobTitle
FROM HR.Employee
WHERE JobTitle='Design Engineer'

Output

SQL Where Clause 

Where clause can be used with below Operators 

OperatorDescription
= Equal
<> Note equal. Note: Some of SQL version support this operator can be written as !=
> Greater than
< Less than
>= Greater than equal to
<= Less than equal to
BETWEEN Between an inclusive range
Like Search for a pattern
IN To specify multiple possible values for a column
AND To specify multiple AND condition
OR To specify multiple OR condition

Share this chapter
Comments
comments powered by Disqus

Navigation

Social Media