search
HomeDaily ProgrammingMysql KnowledgeHow 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).

How to write not equal to multiple in mysql

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:

  • order_id
  • customer_id
  • product_id

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.
  • For larger lists of values, it is recommended to use subqueries or temporary tables.

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!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software