The IN operator allows you to specify multiple values in a WHERE clause.
Sql IN Syntax:
Let's create the table we will use
Script:
Check the table to see the data and the structure.
Very good
Now let us use the IN operator.
Example :
-let's see all the names that have id equal to 1,2,3.
is pretty simple, you just put your option in the parentheses as the condition and here you go.
Note:
is not necessary that all the values that are in the IN operator to be true so that the query would work. We can throw values that don't exist in our table but we won't get any results.
Example :
we see that the query only shows two names that are related to first two values declared in the IN operator.
Example :
-we can write this query like this as well and it has the same action