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)