Latest web development tutorials

SQL IN-Operator

IN-Operator

IN-Operator ermöglicht es Ihnen, mehrere Werte in der WHERE-Klausel angegeben.

SQL Syntax

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


Die Demo-Datenbank

In diesem Tutorial werden wir w3big Beispieldatenbank verwenden.

Hier finden Sie eine ausgewählte "Websites" Tabellendaten:

+----+--------------+---------------------------+-------+---------+
| id | name         | url                       | alexa | country |
+----+--------------+---------------------------+-------+---------+
| 1  | Google       | https://www.google.cm/    | 1     | USA     |
| 2  | 淘宝          | https://www.taobao.com/   | 13    | CN      |
| 3  | 本教程      | http://www.w3big.com/    | 4689  | CN      |
| 4  | 微博          | http://weibo.com/         | 20    | CN      |
| 5  | Facebook     | https://www.facebook.com/ | 3     | USA     |
| 7  | stackoverflow | http://stackoverflow.com/ |   0 | IND     |
+----+---------------+---------------------------+-------+---------+


IN-Operator Beispiele

Die folgende SQL-Anweisung select name als "Google" oder "natürlich" aller Seiten:

Beispiele

SELECT * FROM Websites
WHERE name IN ( "Google", "Tutorial");

Die Ausführung Ausgabe: