title: Mysql Case Statement syntax
body: <p>Can anyone tell me where the syntax aerror here is:</p>
  
  <pre><code>SELECT `t`.*, `u`.`first_name`, `u`.`second_name` 
  FROM `tickets` `t`
  
  (CASE WHEN `t`.`user_id` IS NOT NULL
  THEN 
  JOIN `adminbb` `u` ON `t`.`admin_id`=`u`.`admin_id`
  ELSE 
  JOIN `users` `u` ON `t`.`user_id`=`u`.`user_id`
  END) 
  
  WHERE `t`.`ticket_id` =1
  ORDER BY  `t`.`ticketText_id` 
  LIMIT 0,3
  </code></pre>
  
  <p>Error says: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(CASE WHEN <code>t</code>.<code>user_id</code> IS NOT NULL THEN JOIN <code>adminbb</code> <code>u</code> ON <code>t</code>.`admin_id' at line 3</p>
  
  <p>Thanks Alan.</p>