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 > Using 'Case' statement inside 'Where' clause

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-02-11, 07:33
er_debraj er_debraj is offline
Registered User
 
Join Date: Jun 2011
Posts: 2
Red face Using 'Case' statement inside 'Where' clause

Hi,

I am all messed up putting an appropriate case statement into my 'where' clause but no correct results obtained yet, is there any way to do the following?

Can anyone tell me the code for:-

SELECT `column1`,`column2`,`column3`,`column4`, `column5`,`column6` ,`column7` FROM `tablename` WHERE `column7`NOT IN
CASE `column2`
WHEN '1' THEN ( 'abcd','efgh','ijkl','mnop')
WHEN '2' THEN ' '
END
and `column6`>='0' order by `column2`,`column6`

Thanks in advance
Reply With Quote
  #2 (permalink)  
Old 06-02-11, 08:09
healdem healdem is offline
Jaded Developer
 
Join Date: Nov 2004
Location: out on a limb
Posts: 9,250
Id suggest a sub select query
__________________
I'd rather be riding my Versys or my Tiger 800 let alone the Norton
Reply With Quote
Reply

Tags
case when, mysql, select, switch, where clause

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