Home > Article > Daily Programming > How to write not equal to multiple in mysql
In MySQL, you can use the NOT IN operator to query not equal to multiple values. The syntax is: SELECT column_name(s) FROM table_name WHERE column_name NOT IN (value1, value2, ..., valueN). For example, to find orders with a product ID that is not 10, 20, or 30, you would use the query: SELECT order_id FROM orders WHERE product_id NOT IN (10, 20, 30).
Not equal to multiple values in MySQL
In MySQL, use NOT IN
Operators can be implemented not equal to multiple values. Its syntax is as follows:
<code>SELECT column_name(s) FROM table_name WHERE column_name NOT IN (value1, value2, ..., valueN);</code>
Example
Suppose there is a table named "orders" with the following fields:
To find all orders that do not belong to the following product IDs, you can use the following query:
<code>SELECT order_id FROM orders WHERE product_id NOT IN (10, 20, 30);</code>
This will return All orders where product_id
is not 10, 20 or 30.
Note:
NOT IN
The operator can specify up to 65535 values at a time. The above is the detailed content of How to write not equal to multiple in mysql. For more information, please follow other related articles on the PHP Chinese website!