In this Oracle tutorial, we will learn how to use IN condition in SQL. IN condition is used in SQL with every database.
IN condition helps to check multiple values in a column or we can say, it reduces the use of OR condition in a SQL statement.
As it is a condition and helps to limit the rows to be returned by SQL statement, it is used just after the WHERE clause.
Syntax-1: Using the expressions list
Syntax-2: Using the subquery/select query
Parameters or Arguments:
This is the column of the table in which we need to look the values.
value1, value2, … value_n
These are values that we need to check in the specified column. These values should be aligned between single quotes and comma separated as these are char values.
This is a SELECT statement whose result set will be tested against the values in the specified column.
Below explample is showing how we can select a few rows from Employees table (HR schema) using equality operator.
Example-2 will show how easy it is when we use IN condition.
Both the SQL statements will give the same output but IN condition helps to shorten the code.
Example-3 will show you how we can we a select statement in IN condition.
Eventually, 3rd example shows both methods of using IN condition in SQL statement.
When we supply char values to the IN condition, we can only supply 1000 values.
If you have any questions/suggestions, please comment below or write me an email.
If you like this blog, do share with your friends and colleagues on your social media.
For more updates join my facebook group and do like my facebook page.