I need to get data from a table with <NULL> in a date field. My query looks
something like this:
select batch_id, visit, reg_date
from daily_batch
where cpi = 6800 and post_date = NULL
This should bring back a record but it does not. cpi 6800 exists and the
post_date field is <NULL>.
What am I doing wrong?
Robert HillUse IS NULL instead.
select batch_id, visit, reg_date
from daily_batch
where cpi = 6800 and post_date is NULL
AMB
"Robert" wrote:
> I need to get data from a table with <NULL> in a date field. My query loo
ks
> something like this:
> select batch_id, visit, reg_date
> from daily_batch
> where cpi = 6800 and post_date = NULL
> This should bring back a record but it does not. cpi 6800 exists and the
> post_date field is <NULL>.
>
> What am I doing wrong?
> --
> Robert Hill
>|||NULL equates to unknown, it has no value
You need to change your where to:
where cpi = 6800 and post_date IS NULL
Look up the following in BOL
NULL Comparison Search Conditions
"Robert" <rhill938@.hotmail.com> wrote in message
news:CB56F046-EF25-4DF9-BB1F-938733F40BD8@.microsoft.com...
> I need to get data from a table with <NULL> in a date field. My query
looks
> something like this:
> select batch_id, visit, reg_date
> from daily_batch
> where cpi = 6800 and post_date = NULL
> This should bring back a record but it does not. cpi 6800 exists and the
> post_date field is <NULL>.
>
> What am I doing wrong?
> --
> Robert Hill
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment