SELECT `profiles`.*
FROM `profiles`
INNER JOIN `friendships`
ON `profiles`.id = `friendships`.(CASE WHEN friendships.profile_id = 1
THEN`friend_id` ELSE `profile_id` END)
내 inner.properties.id = friendships (여기에 필요한 하나의 키를 선택합니다)와 같은 내부 조인을 만들 수 있지만 작동하지 않습니다. 도와주세요 : PMYSQL의 경우 문제가
을가 캔트 :
`profiles`.id = (CASE WHEN friendships.profile_id = 1
THEN `friendships`.`friend_id` ELSE `friendships`.`profile_id` END)
여기에 문제가 내가 레일을 사용하는 것이 내가이 사용 방법 : foreign_key => '사건을 .. . '그리고 나는 friendships.friendships.profile_id'을 얻었 기 때문에 우정을 사용하지 못했습니다. 어쨌든 덕분에 –
죄송합니다, 레일에 익숙하지 않습니다. – Andrey