Wednesday, March 28, 2012

Query problem

I want to restrict the results of a query only where the field 'email' has
something in it. I had a record with data in 'email' and deleted it and my
query still returns the record even thoug part of my statements reads:
Select * from Users
Where email is NOT NULL OR email <> ''
Even though I deleted what was in the 'email' field I still get the
recordset and the email field is blank.
Any clues ?
AleksHow can we reproduce the problem?
Please provide DDL and sample data.
http://www.aspfaq.com/etiquette.asp?id=5006
AMB
"Aleks" wrote:

> I want to restrict the results of a query only where the field 'email' has
> something in it. I had a record with data in 'email' and deleted it and my
> query still returns the record even thoug part of my statements reads:
> Select * from Users
> Where email is NOT NULL OR email <> ''
> Even though I deleted what was in the 'email' field I still get the
> recordset and the email field is blank.
> Any clues ?
> Aleks
>
>|||Aleks wrote:
> I want to restrict the results of a query only where the field
> 'email' has something in it. I had a record with data in 'email' and
> deleted it and my query still returns the record even thoug part of
> my statements reads:
> Select * from Users
> Where email is NOT NULL OR email <> ''
> Even though I deleted what was in the 'email' field I still get the
> recordset and the email field is blank.
>
Change "OR" to "AND".
When you deleted the contents, you likely did not set the field to Null, so
"email is NOT NULL" evaluates to True, resulting in the OR expression
evaluating to True.
Better yet, do something like this:
Where email > CHAR(1)
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.

No comments:

Post a Comment