| ★ wanayoo — archive 1999 http://wdvl.com/Authoring/DB/Intro/in.html | Nouvelle recherche | Portail wanayoo |
|
|||
InSeptember 13, 1998
Like BETWEEN, the IN operator is used as a shorthand to specify multiple parameters in one statement. The IN operator looks generically like:
SELECT column_name
FROM table_name
WHERE column_name IN ('value', 'value', value);
The reverse, or course, looks like:
SELECT column_name
FROM table_name
WHERE column_name NOT IN ('value', 'value', value);
As you might have guessed, the IN operator works just the same as stringing multiple OR's together. The list of comma separated values defines a set of acceptable conditions. Thus, to get a listing of all the clients in the 90031 or the 90102 zip codes, you could string together OR operators such as:
SELECT C_NAME, C_ZIP FROM CLIENTS WHERE C_ZIP = 90031 OR C_ZIP = 90102; Or using the IN operator, you would have:
SELECT C_NAME, C_ZIP
FROM CLIENTS
WHERE C_ZIP IN ('90031', '90102');
In either case, you'd get the following results:
C_NAME C_ZIP
-------------------------------
Rick Tan 90031
Stephen Petersen 90102
-------------------------------
Introduction to Databases for the Web | Table of Contents Like | |||
Instantly look up a "techie" word using
Webopedia!!
|
internet.com
| |
e-commerce
| |
WebDeveloper Network
|
Copyright 1999 internet.com Corporation. Legal Notices. Privacy Policy.