Subject Re: [firebird-support] SOME or ANY
Author Helen Borrie
At 10:10 AM 2/07/2003 +0000, you wrote:
>Hi Folks,
> I was looking in the Interbase sql reference and noticed that
>firebird supports SOME and ANY in the where clause, ie
>
>select * from test where price < some (select price from components
>where ...)
>and
>select * from test where price < any (select price from components
>where ...)
>
>Whats the difference between SOME and ANY? I've looked on the web
>with no success.

There's no difference. It just "sounds better" to use one rather than the
other, according to Jim Melton (who was the editor of the SQL standard).

I can see a semantic trap in this, though.

select * from test where price < any (select price from components
where ...)
doesn't mean "find all rows where price is less than any of the prices in
the subquery". It means "find all rows where price is less than at least
one price in the subquery."

To get the semantic equivalent of the English "less than any" you'd need to use

select * from test where price < all (select price from components
where ...)
and I think min() would be cheaper.

heLen