sheena2994

Untitled

Dec 14th, 2016
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. select distinct a.id,a.sender_id,a.recr_id,
  2. case when a.image = "" then 0 else 1 end as is_image,
  3. case when a.image = "" then a.message else concat(
  4.  
  5.  
  6. IF(LOCATE("jpg",a.image) ,CONCAT("https://www.planmymedicaltrip.com/chat/", SUBSTRING_INDEX(SUBSTRING_INDEX(a.image, ".", 1), ".", "-1"), "/", SUBSTRING_INDEX(SUBSTRING_INDEX(a.image, ".", 2), ".", "-1")), "/uploads/chat/a.image")
  7.  
  8.  
  9. ) end as message,
  10. case
  11. when COALESCE( round( TIME_TO_SEC(TIMEDIFF("2016-12-14 16:49:18",a.updated_at ))/2592000,0),"")>12 then
  12. COALESCE(concat( round( TIME_TO_SEC(TIMEDIFF("2016-12-14 16:49:18",a.updated_at ))/31536000,"")," Year(s) Ago"),"")
  13. when COALESCE( round( TIME_TO_SEC(TIMEDIFF("2016-12-14 16:49:18",a.updated_at ))/86400,0),"")>30 then
  14. COALESCE(concat( round( TIME_TO_SEC(TIMEDIFF("2016-12-14 16:49:18",a.updated_at ))/2592000,"")," Month(s) Ago"),"")
  15. when COALESCE( round( TIME_TO_SEC(TIMEDIFF("2016-12-14 16:49:18",a.updated_at ))/3600,0),"")>24 then
  16. COALESCE(concat( round( TIME_TO_SEC(TIMEDIFF("2016-12-14 16:49:18",a.updated_at ))/86400,"")," Day(s) Ago"),"")
  17.  
  18. when COALESCE( round( TIME_TO_SEC(TIMEDIFF("2016-12-14 16:49:18",a.updated_at ))/60,0),"")>60 then
  19. COALESCE(concat( round( TIME_TO_SEC(TIMEDIFF("2016-12-14 16:49:18",a.updated_at ))/3600,"")," Hour(s) Ago"),"")
  20. else
  21. COALESCE( concat(round( TIME_TO_SEC(TIMEDIFF("2016-12-14 16:49:18",a.updated_at ))/60,"")," Min(s) Ago"),"")
  22. end as last_active,a.updated_at,a.created_at
  23. from chat as a
  24. where (
  25. (a.sender_id =760 and a.recr_id =999) or
  26. (a.recr_id =760 and a.sender_id =999)
  27. )
  28. and ( case when a.sender_id = 760 then delete_via_user1 <> 760 else delete_via_user2<>760 end )
  29.  
  30. order by a.id desc
  31. limit 50
Add Comment
Please, Sign In to add comment