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
This query retrieves rows where the id column matches either 3 or 4.
IN Clause:
SELECT * FROM table WHERE id IN (3,4)
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!