DB2 graphic  QMF Version 8

Selecting rows using the IN predicate

You can use one IN statement to replace multiple OR statements.

Both of the following queries select the same rows to view on the report:

SELECT ID, NAME, YEARS, SALARY
  FROM Q.STAFF
  WHERE DEPT = 38 OR DEPT = 20 OR DEPT = 42

SELECT ID, NAME, YEARS, SALARY
  FROM Q.STAFF
  WHERE DEPT IN (38, 20, 42)

And

Use NOT with the IN statement to specify rows you do not want to select, as in the following example:

WHERE DEPT NOT IN (15, 20, 38)


Go to the previous page Go to the next page

Downloads | Library | Support | Support Policy | Terms of use | Feedback
Copyright IBM Corporation 1982,2004 Copyright IBM Corporation 1982, 2004
timestamp Last updated: March, 2004