MYSQL CASE WHEN PROBLEM

Posted by user305270 on Stack Overflow See other posts from Stack Overflow or by user305270
Published on 2010-03-30T17:52:15Z Indexed on 2010/03/30 18:03 UTC
Read the original article Hit count: 377

Filed under:
|
    SELECT `profiles`.* 
    FROM `profiles` 
    INNER JOIN `friendships` 
    ON `profiles`.id = `friendships`.(CASE WHEN friendships.profile_id = 1
    THEN`friend_id` ELSE `profile_id` END)

How can i make the inner join like profile.id = friendships.(here will select the one key that is needed) but it doesnt work. please help :P

it cant be:

         `profiles`.id =  (CASE WHEN friendships.profile_id = 1
         THEN `friendships`.`friend_id` ELSE `friendships`.`profile_id` END)

© Stack Overflow or respective owner

Related posts about mysql

Related posts about case