SQL-W3School- Advanced: SQL IN operator

ylbtech-SQL-W3School- Advanced: SQL IN operator

 

1. Back to top
1、

IN operator

IN operator allows us plurality of values specified in the WHERE clause .

SQL IN grammar

SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1,value2,...)

The original table (used in Example :)

Persons table:

Id LastName FirstName Address City
1 Adams John Oxford Street London
2 Bush George Fifth Avenue New York
3 Carter Thomas Changan Street Beijing

IN operator Example

Now we want to choose people from the table last name is Adams and Carter are:

We can use the following SELECT statement:

SELECT * FROM Persons
WHERE LastName IN ('Adams','Carter')

The results set:

Id LastName FirstName Address City
1 Adams John Oxford Street London
3 Carter Thomas Changan Street Beijing
2、
2. Return to top
 
3. Back to top
 
4. Top
 
5. Top
1、
2、
 
6. Back to top
 
warn Author: ylbtech
Source: http://ylbtech.cnblogs.com/
This article belongs to the author and blog Park total, welcome to reprint, but without the author's consent declared by this section must be retained, and given the original connection in the apparent position of the article page, otherwise reserves the right to pursue legal responsibilities.

Guess you like

Origin www.cnblogs.com/storebook/p/11805759.html