title: Postgresql case and testing boolean fields
body: <p>First: I'm running postgresql 8.2 and testing my queries on pgAdmin.</p>
  
  <p>I have a table with some fields, say:</p>
  
  <pre><code>mytable(
    id integer,
    mycheck boolean,
    someText varchar(200));
  </code></pre>
  
  <p>Now, I want a query similary to this:</p>
  
  <pre><code> select id,
    case when mycheck then (select name from tableA)
         else (select name from tableB) end as mySpecialName,
    someText;
  </code></pre>
  
  <p>I tried to run and get this:</p>
  
  <pre><code>ERROR: CASE types character varying and boolean cannot be matched
  SQL state: 42804
  </code></pre>
  
  <p>And  even trying to fool postgresql with</p>
  
  <pre><code>case (mycheck::integer) when 0 then
  </code></pre>
  
  <p>didn't work.</p>
  
  <p>So, my question is: since sql doesn't have if, only case, how I'm suppose to do an if with a boolean field?</p>