xxxxxxxxxx
(IN) operator in sql like "OR" operator
For example:
Select * From employees
Where department_id "IN" (60,90);
xxxxxxxxxx
Used alongside a WHERE clause as a shorthand for multiple OR conditions.
So instead of:
SELECT * FROM users
WHERE country = 'USA' OR country = 'United Kingdom' OR
country = 'Russia' OR country = 'Australia';
You can use:
SELECT * FROM users
WHERE country IN ('USA', 'United Kingdom', 'Russia',
'Australia');
xxxxxxxxxx
-- IN is a shortcut of OR for a list of values that exist in same column
SELECT col1, col2
FROM table_name
WHERE col2 = 'A' AND (col1 = 1920 OR col1 = 1930 OR col1 = 1940);
-- Now since col1 has multiple values with OR, we can replace these OR with IN
SELECT col1, col2
FROM table_name
WHERE col2 = 'A' AND col1 IN (1920, 1930, 1940);
xxxxxxxxxx
SELECT EmpId FROM EmployeeDetails
UNION
SELECT EmpId FROM EmployeeSalary;
xxxxxxxxxx
SELECT EmpId,
Salary+Variable as TotalSalary
FROM EmployeeSalary;
xxxxxxxxxx
(IN) operator in sql like "OR" operator
For example:
Select * From employees
Where department_id "IN" (60,90);
xxxxxxxxxx
SELECT FullName
FROM EmployeeDetails
WHERE FullName LIKE ‘__hn%’;