The IN operator allows you to specify multiple values in a WHERE clause.
SQL IN Syntax
SELECT column_name(s) FROM table_name WHERE column_name IN (value1,value2,...)
IN Operator Example
The "Persons" table:
P_Id | LastName |FirstName |Address |City
1 Kumar Ravi Navi mumbai 10 kamlapark bombay
2 walia Ashwin 5 shivajinagar jaipur
3 gupta prakash 1 manit bhopal
Now we want to select the persons with a last name equal to “Kumar" or “gupta" from the table above.
We use the following SELECT statement:
SELECT * FROM Persons WHERE LastName IN (‘Kumar',' gupta ');
The result-set will look like this:
P_Id |LastName | FirstName | Address |City
1 Kumar RaviNavi mumbai10 bombay
3 gupta prakash 1 manit bhopal
BAHUT ACHA HAI
ReplyDelete