exists is used to check if a subquery returns at least one row of data, and the subquery does not actually return any data, but instead returns a value of True or false
EXISTS Specifies a subquery that detects the existence of a row.
The use of exists and in efficiency, usually using exists is higher than in efficiency, because in does not walk the index, but depends on the actual use of:
In the case of large appearance and small inner table, exists is suitable for small appearance and large inner table.
Example: (EXISTS)
SELECT * FROM dbo. Purchasesettleaccountsdetails d where exists (SELECT * FROM dbo. Purchasesettleaccounts where Approvalstatus=1 and Id=d.purchasesettleaccountid)
(in)
SELECT * FROM dbo. Purchasesettleaccountsdetails D where Purchasesettleaccountid in (the Select ID from dbo. Purchasesettleaccounts where Approvalstatus=1 and Id=d.purchasesettleaccountid)
SQL EXISTS and in