select a.provider_id,a.lead_id,notification, e.name as 'providername' , e.email as 'provideremail' , c.name as 'leadname' , c.email as 'leademail' , d.servicecategoryname as 'categoryname', e.accesscode as 'provideraccesscode', c.accesscode as 'leadaccesscode', a.last_changed_by from localpro_chat as a left outer join localpro_provider as e on e.id = a.provider_id left outer join localpro_leads as c on c.id = a.lead_id left outer join servicecategory as d on c.category_id = d.id where notification='QUEUED' and last_changed < NOW() - INTERVAL 1 MINUTE