title: Left outer join - how to return a boolean for existence in the second table?
body: <p>In PostgreSQL 9 on CentOS 6 there are 60000 records in <code>pref_users</code> table:</p>
  
  <pre><code># \d pref_users
                     Table "public.pref_users"
     Column   |            Type             |     Modifiers      
  ------------+-----------------------------+--------------------
   id         | character varying(32)       | not null
   first_name | character varying(64)       | not null
   last_name  | character varying(64)       | 
   login      | timestamp without time zone | default now()
   last_ip    | inet                        | 
   (... more columns skipped...)
  </code></pre>
  
  <p>And another table holds around 500 ids of users which are not allowed to play anymore:</p>
  
  <pre><code># \d pref_ban2
                   Table "public.pref_ban2"
     Column   |            Type             |   Modifiers   
  ------------+-----------------------------+---------------
   id         | character varying(32)       | not null
   first_name | character varying(64)       | 
   last_name  | character varying(64)       | 
   city       | character varying(64)       | 
   last_ip    | inet                        | 
   reason     | character varying(128)      | 
   created    | timestamp without time zone | default now()
  Indexes:
      "pref_ban2_pkey" PRIMARY KEY, btree (id)
  </code></pre>
  
  <p>In a PHP script I am trying to display all 60000 users from <code>pref_users</code> in a jQuery-dataTable. And I would like to mark the banned users (the users found in <code>pref_ban2</code>).</p>
  
  <p>Which means I need a column named <code>ban</code> for each record in my query holding <code>true</code> or <code>false</code>.</p>
  
  <p>So I am trying a <strong>left outer join</strong> query:</p>
  
  <pre><code># select                          
         b.id,  -- how to make this column a boolean?
         u.id, 
         u.first_name, 
         u.last_name, 
         u.city,
         u.last_ip,
         to_char(u.login, 'DD.MM.YYYY') as day
  from pref_users u left outer join pref_ban2 b on u.id=b.id
  limit 10;
   id |    id    | first_name  | last_name |    city     |     last_ip     |    day     
  ----+----------+-------------+-----------+-------------+-----------------+------------
      | DE1      | Alex        |           | Bochum      | 2.206.0.224     | 21.11.2014
      | DE100032 | Княжна Мэри |           | London      | 151.50.61.131   | 01.02.2014
      | DE10011  | Aлександр Ш |           | Симферополь | 37.57.108.13    | 01.01.2014
      | DE10016  | Semen10     |           | usa         | 69.123.171.15   | 25.06.2014
      | DE10018  | Горловка    |           | Горловка    | 178.216.97.214  | 25.09.2011
      | DE10019  | -Дмитрий-   |           | пермь       | 5.140.81.95     | 21.11.2014
      | DE10047  | Василий     |           | Cумы        | 95.132.42.185   | 25.07.2014
      | DE10054  | Maedhros    |           | Чикаго      | 207.246.176.110 | 26.06.2014
      | DE10062  | ssergw      |           | москва      | 46.188.125.206  | 12.09.2014
      | DE10086  | Вадим       |           | Тула        | 109.111.26.176  | 26.02.2012
  (10 rows)
  </code></pre>
  
  <p>As you can see the <code>b.id</code> column above is empty - because these 10 users aren't banned.</p>
  
  <p>How to get a <code>false</code> value in that column instead of a String?</p>
  
  <p>And I am not after some <code>coalesce</code>or <code>case</code> expression, but am looking for "the proper" way to do such a query.</p>