DEMO SQL Database
We will use the following SQL table for our examples below:
Fname | Lname | Ssn | Bdate | Address | Sex | Salary |
---|---|---|---|---|---|---|
Chiranjeev | Singh | 1 | 2002-07-31 | Delhi | M | 1111789.00 |
Harry | Stark | 2 | 1990-07-31 | Delhi | M | 3333.00 |
Meghna | Gururaani | 5 | 2002-04-04 | Almora | F | 3433.00 |
Aniket | Bhardwaj | 6 | 2001-05-05 | Ponta | M | 56564.00 |
Vritti | Goel | 7 | 2002-03-05 | Delhi | F | 7565.00 |
Aashish | Kumar | 8 | 2002-08-04 | Himachal | M | 44657.00 |
Siddharth | Chaturvedi | 9 | 2003-11-10 | Lucknow | M | 244322.00 |
You can create the following table using these queries:
CREATE TABLE Employee (
Fname VARCHAR(50),
Lname VARCHAR(50),
Ssn INT,
Bdate DATE,
Address VARCHAR(100),
Sex CHAR(1),
Salary DECIMAL(10, 2)
);
INSERT INTO Employee (Fname, Lname, Ssn, Bdate, Address, Sex, Salary) VALUES
('Chiranjeev', 'Singh', 1, '2002-07-31', 'Delhi', 'M', 1111789.00),
('Harry', 'Stark', 2, '1990-07-31', 'Delhi', 'M', 3333.00),
('Meghna', 'Gururaani', 5, '2002-04-04', 'Almora', 'F', 3433.00),
('Aniket', 'Bhardwaj', 6, '2001-05-05', 'Ponta', 'M', 56564.00),
('Vritti', 'Goel', 7, '2002-03-05', 'Delhi', 'F', 7565.00),
('Aashish', 'Kumar', 8, '2002-08-04', 'Himachal', 'M', 44657.00),
('Siddharth', 'Chaturvedi', 9, '2003-11-10', 'Lucknow', 'M', 244322.00);
SQL IN Operator
The SQL IN operator filters data based on a list of specific values. In general, we can only use one condition in the WHEN clause, but the IN operator allows us to specify multiple values.
In this article, we will learn about the IN operator in SQL by understanding its syntax and examples.
Contact Us