title: SQL DB2 - conditional logic in WHERE clause
body: <p>I need to pull back records based on a location ID, but I've got two fields that MAY contain the incoming criteria....</p>
  
  <p>something like this</p>
  
  <pre><code>SELECT * FROM tbl
  WHERE myVar = locationID
      IF LocationID = 0
        myVar = location2ID
  </code></pre>
  
  <p>this is a 'logical' example...</p>
  
  <p>I think I can do </p>
  
  <pre><code>WHERE myVar = CASE WHEN locationID = 0 THEN location2ID ELSE locationID END
  </code></pre>
  
  <p>although I've read that CASE in a WHERE clause should be avoided...? why? or is this OK?
  - either way it FAILS</p>
  
  <pre><code>WHERE CASE WHEN locationID=0 THEN location2ID=myVAr ELSE locationID=myVar END
  </code></pre>
  
  <p>also FAILS</p>
  
  <p>thx</p>
  
  <p>Sorry for the confusion lads - didn't mean to be "ambiguous" - looks like #2 will do what I want - but for the clarification requested here is the issue...</p>
  
  <p>the table stores TWO locations, let's call then CURRENT_LOC and ORIGINAL_LOC... in most cases these will BOTH have data, but in some cases the 'thing' hasn't moved... so the CURRENT_LOC is '0'. MY issue is I'll be passing in a LOCATION ID, I want the records where CURRENT_LOC matches OR if the the CURRENT_LOC=0 then I ALSO want the ORIGINAL_LOC... where that matches...</p>
  
  <p>does that help the discussion? I hope. </p>