Advertisement
Guest User

Untitled

a guest
Nov 18th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. select c1.to_user as Con1, c2.from_user as Con2 , person.user_id, person.profile_image,d.type,
  2. concat(person.first_name,' ',person.last_name) AS full_name,
  3. @IsConn := if( coalesce( c1.to_user, c2.from_user), 'yes','no') as IsConnected,
  4. CASE
  5. WHEN d.type=1 AND @IsConn='no' THEN 'connect'
  6. WHEN d.type=1 AND @IsConn='yes' THEN 'Disconnect'
  7. WHEN d.type=2 AND @IsConn='no' THEN 'Follow'
  8. WHEN d.type =2 AND @IsConn='yes' THEN 'Unfollow'
  9. END AS button,
  10. user.username, if(d.type =1,'Disconnect','Unfollow') as btn_txt
  11. from
  12. ( select to_user as ConId ,type from connection
  13. where
  14. from_user=$profileId and status=2
  15. UNION
  16. select from_user as ConId ,type from connection
  17. where to_user=$profileId and status=2) d
  18. JOIN person ON person.user_id = d.ConId
  19. JOIN user ON person.user_id = user.user_id
  20. left join connection c1 on c1.from_user=$loginId and c1.to_user=d.ConId
  21. 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