Home > Database > Mysql Tutorial > body text

How to Select Rows Based on Multiple Values in MySQL?

DDD
Release: 2024-10-31 05:39:30
Original
517 people have browsed it

How to Select Rows Based on Multiple Values in MySQL?

Selecting Multiple Values in MySQL Queries

In this scenario, you aim to retrieve specific rows based on multiple criteria, such as identifying individuals by their IDs (3 and 4) or names (andy and paul) within a table.

To achieve this, you can utilize the following syntax:

OR Condition:

SELECT * FROM table WHERE id = 3 OR id = 4
Copy after login

This query retrieves rows where the id column matches either 3 or 4.

IN Clause:

SELECT * FROM table WHERE id IN (3,4)
Copy after login

Alternatively, you can use the IN clause to specify a list of values to match. In this case, the query selects rows where the id column is either 3 or 4.

The above is the detailed content of How to Select Rows Based on Multiple Values in MySQL?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!