Logo

K-Learn

SQL IN Keyword

< Previous Next >

The SQL IN keyword is used to specify a list of values that you want to match in a query. It is typically used in the WHERE clause of a SELECT statement to filter data based on a specified set of values.

IN Syntax

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

For example,

Let's say we want to retrieve the details of students whose names are either "John" or "Angel" from the student table.

We can write a SQL query using the IN keyword like this:

SELECT * FROM student
WHERE name IN ('John', 'Angel');

OUTPUT

In this above example,

This query will return all the rows from the student table where the name is either "John" or "Angel". The IN keyword is followed by a list of values enclosed in parentheses and separated by commas.


< Previous Next >