I'm using SQL (SQL Server, PostgreSQL) over 10 years and still I'm never used ANY/SOME
and ALL
keywords in my production code. All situation I've encountered I could get away with IN
, MAX
, MIN
, EXISTS
, and I think it's more readable.
For example:
-- = ANY
select * from Users as U where U.ID = ANY(select P.User_ID from Payments as P);
-- IN
select * from Users as U where U.ID IN (select P.User_ID from Payments as P);
Or
-- < ANY
select * from Users as U where U.Salary < ANY(select P.Amount from Payments as P);
-- EXISTS
select * from Users as U where EXISTS (select * from Payments as P where P.Amount > U.Salary);
Using ANY/SOME
and ALL
:
So the question is: am I missing something? is there some situation where ANY/SOME
and ALL
shine over other solutions?