The DIFFERENCE BETWEEN In AND Exists IN SQL

Asked By 0 points N/A Posted on -
qa-featured

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?

SHARE
Answered By 0 points N/A #161910

The DIFFERENCE BETWEEN In AND Exists IN SQL

qa-featured

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)

 

Login/Register to Answer

Related Questions