Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select c1.to_user as Con1, c2.from_user as Con2 , person.user_id, person.profile_image,d.type,
- concat(person.first_name,' ',person.last_name) AS full_name,
- @IsConn := if( coalesce( c1.to_user, c2.from_user), 'yes','no') as IsConnected,
- CASE
- WHEN d.type=1 AND @IsConn='no' THEN 'connect'
- WHEN d.type=1 AND @IsConn='yes' THEN 'Disconnect'
- WHEN d.type=2 AND @IsConn='no' THEN 'Follow'
- WHEN d.type =2 AND @IsConn='yes' THEN 'Unfollow'
- END AS button,
- user.username, if(d.type =1,'Disconnect','Unfollow') as btn_txt
- from
- ( select to_user as ConId ,type from connection
- where
- from_user=$profileId and status=2
- UNION
- select from_user as ConId ,type from connection
- where to_user=$profileId and status=2) d
- JOIN person ON person.user_id = d.ConId
- JOIN user ON person.user_id = user.user_id
- left join connection c1 on c1.from_user=$loginId and c1.to_user=d.ConId
- left join connection c2 on c2.to_user=$loginId and c2.from_user=d.ConId
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement