codingstreets
Search
Close this search box.
sql-in-operator

Get Started: SQL IN Operator

In This Article, You Will Know About SQL Wildcard. 

SQL IN Operator – Before moving ahead, let’s know a bit about SQL Wildcard.

Table of Contents

SQL IN Operator

IN Operator – The SQL IN operator is used for matching/ finding out multiple conditions at once.

The IN operator is used with the WHERE clause. In shorthand, it is used as OR conditions.

Syntax

				
					SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1, value2, ...);
				
			

or:

				
					SELECT column_name(s)
FROM table_name
WHERE column_name IN (SELECT STATEMENT);
				
			

Example Database

Below is the example of a database table named “details.”

Id

Name

Class

section_id

1

Alex

5

1

2

Rolex

6

2

3

Salex

7

2

4

Lelex

8

3

5

Kelex

9

5

IN Operator Example

Example: Use the IN operator to match the multiple conditions.

				
					SELECT * FROM details
WHERE Name IN ('Alex', 'Rolex');
				
			

As a result, it returns the record after matching the condition.

Example: Use the IN operator to match the multiple conditions.

				
					SELECT * FROM details
WHERE Name  NOT IN ('hlex', 'olex');
				
			

As a result, it returns the record after matching the condition.

Example: Use the IN operator to match the multiple conditions.

				
					SELECT * FROM details
WHERE Name IN (SELECT Name FROM Class);
				
			

As a result, it returns the record after matching the condition.

If you find anything incorrect in the above-discussed topic and have further questions, please comment below.

Connect on:

Recent Post

Popular Post

Top Articles

Archives
Categories

Share on