UPDATE `prestashop_CARTOFLEX`.`ps_customer_thread` SET `status` = 'closed' WHERE `ps_customer_thread`.`status` = 'open'; UPDATE `prestashop_CARTOFLEX`.`ps_customer_thread` SET `status` = 'closed' WHERE `ps_customer_thread`.`id_customer_thread` =1778; SELECT SQL_CALC_FOUND_ROWS a.* , CONCAT(c.`firstname`," ",c.`lastname`) as customer, cl.`name` as contact, l.`name` as language, group_concat(message) as messages, cm.private, ( SELECT IFNULL(CONCAT(LEFT(e.`firstname`, 1),". ",e.`lastname`), "--") FROM `ps_customer_message` cm2 INNER JOIN ps_employee e ON e.`id_employee` = cm2.`id_employee` WHERE cm2.id_employee > 0 AND cm2.`id_customer_thread` = a.`id_customer_thread` ORDER BY cm2.`date_add` DESC LIMIT 1 ) as employee FROM `ps_customer_thread` a LEFT JOIN `ps_customer` c ON c.`id_customer` = a.`id_customer` LEFT JOIN `ps_customer_message` cm ON cm.`id_customer_thread` = a.`id_customer_thread` LEFT JOIN `ps_lang` l ON l.`id_lang` = a.`id_lang` LEFT JOIN `ps_contact_lang` cl ON (cl.`id_contact` = a.`id_contact` AND cl.`id_lang` = 1) WHERE 1 AND a.`status` LIKE '%closed%' GROUP BY cm.id_customer_thread ORDER BY a.`id_customer_thread` DESC LIMIT 0, 1000