The DIFFERENCE BETWEEN In AND Exists IN SQL
When I was doing my project in SQL command, there is a confusion arisen that what is the difference between In and Exists in SQL. When to use what?
When I was doing my project in SQL command, there is a confusion arisen that what is the difference between In and Exists in SQL. When to use what?
There is a difference between IN and EXISTS in SQL. IN command means inside to outside. Inner query will derive the outer query. EXISTS command means outside to inside. The outer query will derive the inner query. We usually want to run the query with that command that returns the smaller set of results first.
Syntax of IN command:
SELECT column_name(s)
FROM table_name
WHERE column_name IN (value1,value2,…);
Syntax of Exists command:
SELECT column_name
FROM table-name
WHERE EXISTS
(SELECT column-name FROM table-name WHERE condition)
Â