Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- select distinct a.id,a.sender_id,a.recr_id,
- case when a.image = "" then 0 else 1 end as is_image,
- case when a.image = "" then a.message else concat(
- 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")
- ) end as message,
- case
- when COALESCE( round( TIME_TO_SEC(TIMEDIFF("2016-12-14 16:49:18",a.updated_at ))/2592000,0),"")>12 then
- COALESCE(concat( round( TIME_TO_SEC(TIMEDIFF("2016-12-14 16:49:18",a.updated_at ))/31536000,"")," Year(s) Ago"),"")
- when COALESCE( round( TIME_TO_SEC(TIMEDIFF("2016-12-14 16:49:18",a.updated_at ))/86400,0),"")>30 then
- COALESCE(concat( round( TIME_TO_SEC(TIMEDIFF("2016-12-14 16:49:18",a.updated_at ))/2592000,"")," Month(s) Ago"),"")
- when COALESCE( round( TIME_TO_SEC(TIMEDIFF("2016-12-14 16:49:18",a.updated_at ))/3600,0),"")>24 then
- COALESCE(concat( round( TIME_TO_SEC(TIMEDIFF("2016-12-14 16:49:18",a.updated_at ))/86400,"")," Day(s) Ago"),"")
- when COALESCE( round( TIME_TO_SEC(TIMEDIFF("2016-12-14 16:49:18",a.updated_at ))/60,0),"")>60 then
- COALESCE(concat( round( TIME_TO_SEC(TIMEDIFF("2016-12-14 16:49:18",a.updated_at ))/3600,"")," Hour(s) Ago"),"")
- else
- COALESCE( concat(round( TIME_TO_SEC(TIMEDIFF("2016-12-14 16:49:18",a.updated_at ))/60,"")," Min(s) Ago"),"")
- end as last_active,a.updated_at,a.created_at
- from chat as a
- where (
- (a.sender_id =760 and a.recr_id =999) or
- (a.recr_id =760 and a.sender_id =999)
- )
- and ( case when a.sender_id = 760 then delete_via_user1 <> 760 else delete_via_user2<>760 end )
- order by a.id desc
- limit 50
Add Comment
Please, Sign In to add comment