Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

If in Where Clause for SQL Query

Posted on 2008-10-23
2
Medium Priority
?
372 Views
Last Modified: 2012-05-05
What is the correct syntax for using an IF in a WHERE clause? I need something like


Where IF (A, B='PO', C='OS')

In this example "A" is a logical
B is an Order Type
C is a Status)
0
Comment
Question by:sfletcher1959
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 9

Accepted Solution

by:
jamesgu earned 2000 total points
ID: 22789116
what do you exactly by Where IF (A, B='PO', C='OS')? something like if A is true ues the condition b='PO', otherwise use c='OS'.

If this is what you wanted, use this

where ( condition_a  and B='PO') or (not condition_a  and C='OS')

please give more information
0
 

Author Closing Comment

by:sfletcher1959
ID: 31509340
Thanks!
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In database programming, custom sort order seems to be necessary quite often, at least in my experience and time here at EE. Within the realm of custom sorting is the sorting of numbers and text independently (i.e., treating the numbers as number…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question