The IN operator may be used if you know the exact value you want to return for at least one of the columns.
SELECT columnName FROM tableName WHERE columnName IN (value1,value2, ...); |
The "Books" table:
Title |
Author |
Publisher |
Year |
الدورة الدموية |
إبن النفيس |
دار العلم |
1650 |
Java 2 |
L. Johnston |
Fast Press |
2002 |
Linux and Unix |
J. Sam |
Fast Press |
2004 |
Operating Systems |
M. Stone |
Coriolis |
2005 |
Web Programming |
K. Yariv |
East Edition |
2005 |
XML Language |
M. Salim |
Knowledge Press |
2000 |
To display the books published in 2000 or 2002, we use the following SQL:
SELECT * FROM Books WHERE Year IN (2000,2002); |
The result is:
Title |
Author |
Publisher |
Year |
Java 2 |
L. Johnston |
Fast Press |
2002 |
XML Language |
M. Salim |
Knowledge Press |
2000 |
To test your SQL skills click here.