1
我有以下SQL查詢。我想在laravel查詢生成器中實現相同的查詢。但沒有運氣。可以幫助我如何建立這個。Laravel Query Builder中的條件連接查詢
SELECT DISTINCT IF(follower_id = 1, leader_id, follower_id) as user_id,U.email,T.name FROM `followers` as F JOIN users as U ON IF(follower_id = 1, U.id = F.leader_id,U.id=F.follower_id) JOIN timelines as T ON U.timeline_id = T.id where F.follower_id = 1 OR F.leader_id =1
我不如何在Laravel查詢生成器中添加此條件
ON IF(follower_id = 1, U.id = F.leader_id,U.id=F.follower_id)
。