sql query and WHERE condition

R

rum23

How do I accomplish this via an SQL query? I don't know how to put the
condition in the WHERE clause (Show below) in an sql query. Please help.

Select table1.A, table1.B, table1.c, table2.c
From table1, table2
WHERE
if IsNull(table1.c) then
'do nothing
endif
if not isNUll(table1.c) then
table1.c = table2.c
endif

Thanks
 
L

Lou

How do I accomplish this via an SQL query? I don't know how to put the
condition in the WHERE clause (Show below) in an sql query. Please help.

Select table1.A, table1.B, table1.c, table2.c
From table1, table2
WHERE
        if IsNull(table1.c) then
                'do nothing
        endif
        if not isNUll(table1.c) then
                table1.c = table2.c
        endif

Thanks

Select table1.A, table1.B, table1.c, table2.c
From table1 inner join table2
on table1.c = table2.c

Isn't it true that a NULL value is never equal to another NULL value.
That's why we use the expression "is not null".

But why do you repeat table1.c value when you know table2.c has the
same value?
 
J

John Spencer

What are you trying to accomplish?
Are you trying to update the value in table1.C to a value in Table2.C?


'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
K

Ken Sheridan

Yep. And moreover a NULL is never not equal to a real value. In each case
the result is NULL.

In fact NULL is not a value at all, but the absence of a value. About the
nearest you can get to a meaning for it is 'unknown'. i.e. it might be any
possible value. If you think of it as such then it makes sense, in that
'unknown = unknown' must result in unknown as in either case what is unknown
might or might not be the same value. Similarly '123 = unknown' or '123 <>
unknown', or any comparison operation for that matter, must also result in
unknown as the unknown might or might not be 123.

Its necessary to be careful when allowing Nulls in columns as they are
semantically ambiguous. What would a Null credit rating for a customer mean?
No credit? Unlimited credit? There is simply no way of knowing; it’s
entirely a matter of interpretation not fact.

Ken Sheridan
Stafford, England
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top