
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
In MySQL, how IN() comparison function works?
Basically, IN() comparison function checks whether a value is within a set of values or not. If the value is within a set of values then it returns 1 otherwise 0. Its syntax can be as follows;
Expression IN (val1, val2,…,valN)
Here,
- The expression is the value that is to be searched within the set of N values within IN list.
- Val1, val2,…, valN is the set of N values, forms the IN list, from which the search happens.
Example
mysql> Select 100 IN (50,100,200,400,2000); +------------------------------+ | 100 IN (50,100,200,400,2000) | +------------------------------+ | 1 | +------------------------------+ 1 row in set (0.00 sec) mysql> Select 1000 IN (50,100,200,400,2000); +-------------------------------+ | 1000 IN (50,100,200,400,2000) | +-------------------------------+ | 0 | +-------------------------------+ 1 row in set (0.00 sec) mysql> Select 'ABC' IN ('ABCD','ABCDE','ABC'); +---------------------------------+ | 'ABC' IN ('ABCD','ABCDE','ABC') | +---------------------------------+ | 1 | +---------------------------------+ 1 row in set (0.01 sec) mysql> Select 'ABC' IN ('ABCD','ABCDE','ABCDEF'); +------------------------------------+ | 'ABC' IN ('ABCD','ABCDE','ABCDEF') | +------------------------------------+ | 0 | +------------------------------------+ 1 row in set (0.00 sec)
- Related Articles
- How EXPORT_SET() function works in MySQL?
- How MySQL DATEDIFF() function works?
- How does MYSQL control flow function CASE works?
- How does MySQL QUOTE() function work with comparison values?
- How variable scope works in Python function?
- How can I get the output based on comparison done with column’s name using MySQL IN() function?
- How does comparison operator work with date values in MySQL?
- How to make SQL case sensitive string comparison in MySQL?
- How to use comparison operator for numeric string in MySQL?
- How LIKE operator works with comparison operators for matching specific kinds of patterns of a string?
- Explain how the logistic regression function works with Tensorflow?
- How MySQL can perform case-sensitive string comparison?
- How scriptblock works in PowerShell?
- How "getElementByID" works in JavaScript?
- Display records from two columns based on comparison in MySQL?

Advertisements