We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

SQL WHERE CASE question

simplyfemales
on
Medium Priority
361 Views
Last Modified: 2012-06-27
I need to perform a search based on the following concept

Select A
Where case when G=1 then X in (b,c,d) else X like 'Y' end

No matter what I try, I can't get it to work.

Suggestions?  I know it looks screwy.
Comment
Watch Question

Aaron ShiloChief Database Architect
CERTIFIED EXPERT

Commented:
select A
From table
Where case when G=1 then X in (b,c,d) else X like 'Y' end

Author

Commented:
Ashilo,

My mistake, yes the "from table" is there, the where clause is the portion that's not working.
Aaron ShiloChief Database Architect
CERTIFIED EXPERT

Commented:
ok

it looks like youl need to use a Storedprocedure and build your query dynamicly.
Software Engineer
CERTIFIED EXPERT
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
SharathData Engineer
CERTIFIED EXPERT
Commented:
Unlock this solution with a free trial preview.
(No credit card required)
Get Preview
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a free trial preview!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.