IN :- this operator is used with where clause. it works as prepare search condition. when in any search condition dependent to one or more value then it will written in IN keyword.
Syntax :- select column_name table_name where column_name IN ("value1", "value2", .... , "valuen");
sells table -
Order ID | Order price | Quantity | Cust_name |
1 | 100 | 2 | Aayush |
2 | 65 | 4 | Tarun |
3 | 287 | 1 | Mayuri |
4 | 1050 | 3 | Kavita |
5 | 3000 | 4 | Himanshu |
6 | 425 | 7 | Chetan |
7 | 210 | 2 | Naved |
8 | 777 | NULL | Simran |
9 | 115 | 9 | NULL |
10 | 4000 | 8 | Ravi |
Example :- display all the records of sells table which has quantity either 2 or 4.
i/p :- select * from sells where quantity IN (2,4);
o/p :-
Order ID | Order price | Quantity | Cust_name |
1 | 100 | 2 | Aayush |
2 | 65 | 4 | Tarun |
5 | 3000 | 4 | Himanshu |
7 | 210 | 2 | Naved |
No comments:
Post a Comment