YouTip LogoYouTip

Sql In

# SQL IN Operator * * * ## IN Operator The IN operator allows you to specify multiple values in a WHERE clause. ### SQL IN Syntax SELECT column1, column2, ... FROM table_name WHERE column IN (value1, value2, ...); Parameter Explanation: * **column1, column2, ...**: The name(s) of the field(s) to select. Multiple fields can be specified. If no field name is specified, all fields will be selected. * **table_name**: The name of the table to query. * **column**: The name of the field to query. * **value1, value2, ...**: The value(s) to query. Multiple values can be specified. ## Demo Database In this tutorial, we will use the TUTORIAL sample database. Here is the data selected from the "Websites" table: mysql> SELECT * FROM Websites;+----+---------------+---------------------------+-------+---------+| id | name | url | alexa | country |+----+---------------+---------------------------+-------+---------+| 1 | Google | https://www.google.cm/ | 1 | USA || 2 | Taobao | https://www.taobao.com/ | 13 | CN || 3 | Tutorial | | 5000 | USA || 4 | Weibo | http://weibo.com/ | 20 | CN || 5 | Facebook | https://www.facebook.com/ | 3 | USA || 7 | stackoverflow | http://stackoverflow.com/ | 0 | IND |+----+---------------+---------------------------+-------+---------+ * * * ## IN Operator Example The following SQL statement selects all websites where the name is "Google" or "Tutorial": ## Example SELECT * FROM Websites WHERE name IN ('Google','Tutorial'); Execution output: !(#)
← Sql Create IndexSql Wildcards β†’