SQL LIKE Operator
SQL IN Operator
The IN operator in SQL facilitates a quick search of a value in a given set without the need for complex computation. The function syntax is as shown:
The operator checks if the provided expression is located in the given values. If found, the operator returns TRUE; otherwise, it returns false.
In most cases, you will often pair the IN operator with other clauses, such as the WHERE clause. This can allow you only to fetch values matching a specific condition.
Let us discuss some basic examples of usage of the IN operator in SQL.
Example Usage
The following examples illustrate how to use the IN operator in SQL.
Example 1 – Basic Usage
The example below shows the basic usage of the IN operator.
In the above example, we use the IN operator to check if the string “SQL” is in the given set of values.
Since the string exists, the query should return true, as shown:
Example 2 – Using IN Operator in Table
The following shows how to use the IN operator in conjunction with the WHERE clause in a table.
The table is as shown:
The query should return the matching records as:
Closing
This article shows how to use the IN operator in Standard SQL. The IN operator allows you to check if a given expression is in a set of values.
Source: linuxhint.com