Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

AND question

Status
Not open for further replies.

paultasy

Technical User
May 12, 2004
5
GB
Here's a quick one,,,

I have multiple values that I want to check are all NULL to trigger a condition....

Currently it's

and A=NULL and B=NULL and C=NULL and D=NULL etc etc....

Is there anyway to write the same as something like:

and (A,B,C,D=NULL)?

Thanks
 
IMHO, the correct way is:
and A IS NULL and B IS NULL and C IS NULL and D IS NULL etc etc....

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
thanks for that,
however, what I am really trying to achieve is to
shorten the code if possible?
 
Depending on your DBMS, the following may be allowed.

Code:
where (a,b,c,d) is null
 
doesn't work in Sybase -
oh well, never mind.

The code isn't too cumbersome so I'll stick
with the original form!

Thanks for looking anyway
 
I am not near my database, but does

WHERE a||b||c||d is null;

work? in Oracle that should concatinate the 4 variables into a single value and test the single value

I tried to remain child-like, all I acheived was childish.
 
Be aware that WHERE a||b||c||d is null is true then only one of a,b,c or d is null, which is not the same logic as the original post.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
don't worry, I stuck brackets around it:

and (lbl_bp_cd || pd_cd || cat_it_cd || pric_cd || convert(varchar,age_restr)
|| profit_ctr_cd || rptr_grp_cd || series_grp_cd) is NULL

 
This where clause will not have the same behaviour as the original post.

Hope This Help, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Sponsor

Back
Top