SQL WHERE Clause

      No Comments on SQL WHERE Clause

The SQL WHERE clause is used to fetch the records that fulfill a specified criterion/condition. The condition is specified by the WHERE clause

SQL WHERE Syntax

SELECT column_name,column_name
FROM table_name
WHERE column_name operator value;

Consider a demo database Customer

C.idC.nameC.contactC.address
123eed3Ramesh987654321#12,sec-4 mohali
aa22103Tarun987650000#12,sec-14 b chd
00146hhSia812300912#212,sec-86 panchukula
144dcv4Rahul700912366#001,sec-19 c chd

Where clause example:

SELECT * FROM Customers
WHERE C.name='Sia';

Result:

C.idC.nameC.contactC.address
00146hhSia812300912#212,sec-86 panchukula

NOTE: SQL requires single quotes around text values, but numeric values are not enclosed in quotes.

Operators in The SQL WHERE Clause

OperatorDescription
=Equal
<>Not equal. Note: In some versions of SQL this operator may be written as !=
>Greater than
<Less than
>=Greater than or equal
<=Less than or equal
BETWEENBetween an inclusive range
LIKESearch for a pattern
INTo specify multiple possible values for a column

Leave a Reply

Your email address will not be published. Required fields are marked *