title: MySQL: Use CASE/ELSE value as join parameter
body: <p>I'm trying to join the NAME and PHOTO from USERS table to the TRANSACTIONS table based on who is the payer or payee. It keeps telling me can't find the table <code>this</code> -- What am I doing wrong?</p>
  
  <pre><code>SELECT `name`,`photo`,`amount`,`comment`,
  (
      CASE `payer_id`
      WHEN 72823 THEN `payee_id`
      ELSE `payer_id`
      END
  ) AS `this`
  FROM `transactions`
  RIGHT JOIN `users` ON (`users`.`id`=`this`)
  WHERE `payee_id`=72823 OR `payer_id`=72823
  </code></pre>