SELECT vendor_communications.thread_id, vendor_communications.storefront_id, vendor_communications.status, vendor_communications.user_id, vendor_communications.company_id, vendor_communications.object_id, vendor_communications.object_type, vendor_communications.last_message, vendor_communications.last_message_user_id, vendor_communications.last_message_user_type, vendor_communications.last_updated, vendor_communications.created_at, vendor_communications.communication_type, vendor_communications.subject, companies.company, users.firstname, users.lastname, users.email AS customer_email FROM cscart_vendor_communications AS vendor_communications LEFT JOIN cscart_companies AS companies ON companies.company_id = vendor_communications.company_id LEFT JOIN cscart_users AS users ON users.user_id = vendor_communications.user_id WHERE 1=1 AND vendor_communications.communication_type IN ('vendor_to_customer') AND vendor_communications.status IN ('N') ORDER BY vendor_communications.last_updated desc, vendor_communications.thread_id desc LIMIT 0, 1000000