MySQL Wildcards

MySQL Wildcards

MySQL Aliases

MySQL Aliases

MySQL Data Types

MySQL Data Types

MySQL Interview Questions

MySQL Interview Questions and Answers


MySQL In Operator

The MySQL IN operator helps you to reduce the use of multiple OR conditions in a SELECT, INSERT, UPDATE, or DELETE statement.

MySQL IN OPERATOR Syntax

To reduce the use of multiple OR conditions, use the following syntax:

Syntax

SELECT col1, col2,....
FROM tablename
WHERE expression IN (value1, value2, ...);

OR

SELECT col1, col2,....
FROM tablename
WHERE expression IN (SELECT STATEMENT);

Parameters:

expression : The specified value to test.

value1, value2: Values to test against expression.

MySQL IN OPERATOR example

The following MySQL, IN operator is used reduce the use of multiple OR conditions. If any of these values matches expression, then the IN operator will evaluate to true:

Example

SELECT firstName, lastName, address FROM tblCustomerLoan
WHERE firstName IN ('Yogesh', 'Mahesh');

Note:

In the above example, we are performing IN operator to test the multiple values against expression.

You can use MySQL Command Line Client to perform In operator to test multiple values against expression. It will look like this: