If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Conditional evaluation in where clause

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-29-05, 08:35
ominobufo ominobufo is offline
Registered User
 
Join Date: Feb 2004
Posts: 4
Conditional evaluation in where clause

Hi everybody

I use this expression in my where clause
Code:
((isnull(<value>)) or (colname = <value>))
if I set <value> to NULL the condition is skipped

If I set the <value> to some real value it is evaluated

i am in need of something similar for the IN statement, in that case <value> becomes <values list> but then
Code:
((isnull(<values list>)) or (colname in <values list>))
if <values list> is null the condition is skipped otherwise i get an error because

isnull((2,3,4)) is not accepted by mysql

any suggestion to make this work?
Reply With Quote
  #2 (permalink)  
Old 01-03-06, 10:10
jfulton jfulton is offline
Registered User
 
Join Date: Apr 2005
Location: Baltimore, MD
Posts: 297
I think if you use the COALESCE function in your ISNULL statement, you may get what you are looking for.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On