SQL IN, NOT IN.

Selection with IN, NOT IN

SQL IN operator is used in a where statement, giving you the ability to select rows where a column value exists in a given list of values.

IN Example:
MySQL, Oracle, SQL server, PostgreSQL:
SELECT ADDR_LINE, CITY, US_STATE_CD from addresses
       where US_STATE_CD IN ('CA', 'NY') 
The result should be:
addr_line city us_state_cd
5325 N Sheridan Road Aguanga CA
3871 San Antonio Drive Indio Agoura Hills CA
2581 Richmond Terrace Staten Island Mappleton NY
NOT IN Example:
MySQL, Oracle, SQL server, PostgreSQL:
SELECT ISBN_NO, SHORT_DESC, PUBLISHER from bookstore  
WHERE publisher NOT IN ('Wrox','OReilly');
The result should be:
isbn_no short_desc publisher
0201703092 The Practical SQL, Fourth Edition Addison Wesley
0672325764 Sams Teach Yourself XML in 21 Days, Third Edition Sams Publishing
1590593413 Beginning J2EE 1.4: From Novice to Professional Apress
© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.