You are here: Re: ALL and empty set « MsSQL Server « IT news, forums, messages
Re: ALL and empty set

Posted by Ed Murphy on 10/07/88 11:59

Dimitri Furman wrote:

> Consider this script:
>
> USE pubs
> GO
>
> IF 1 = ALL (SELECT contract FROM dbo.authors WHERE state = 'CA')
> PRINT 'TRUE'
> ELSE
> PRINT 'FALSE'
>
> This, as expected, prints FALSE, since not all authors in CA are under
> contract. Now, if the script is changed as follows:
>
> USE pubs
> GO
>
> IF 1 = ALL (SELECT contract FROM dbo.authors WHERE state = '')
> PRINT 'TRUE'
> ELSE
> PRINT 'FALSE'
>
> then the result is TRUE. In other words, the expression evaluates to TRUE
> when the select statement produces an empty set, which doesn't make sense
> to me. Even more interesting, the expression
>
> NULL = ALL (SELECT contract FROM dbo.authors WHERE state = '')
>
> still evaluates to TRUE (ANSI_NULLS is ON).
>
> Can anyone explain these results? Is this the expected behavior in the SQL
> standard, or something that is specific to SQL Server? Thanks.

It's vacuously true because there are no elements in the set to
produce a non-equality.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация