The IN operator is used in SQL to indicate inclusion, and its syntax is "column_name IN (value1, value2, ...)". Extended representations include NOT IN, ANY, and ALL, which check whether a value is not in a list, exists in a subquery, or exists in all subquery rows.
In SQL, it means containing
In SQL, you can use the IN
operator to express Include. IN
Operator checks whether a value is contained in the specified list.
Syntax:
<code>SELECT column_name FROM table_name WHERE column_name IN (value1, value2, ...)</code>
Example:
Find all employee names that contain specific letters:
<code>SELECT employee_name FROM employees WHERE employee_name IN ('John', 'Mary', 'Bob')</code>
Extended representation:
In addition to the basic IN
operator, SQL also provides the following extended representation:
Example:
Find all orders that do not contain a specific customer:<code>SELECT order_id FROM orders WHERE customer_id NOT IN (12345, 67890)</code>Find all orders that contain at least one over $100 Customer of the order:
<code>SELECT customer_id FROM customers WHERE customer_id IN (SELECT customer_id FROM orders WHERE amount > 100)</code>
The above is the detailed content of How to express inclusion in sql. For more information, please follow other related articles on the PHP Chinese website!