CREATE ALGORITHM = UNDEFINED DEFINER = `ATS`@`localhost` SQL SECURITY DEFINER VIEW `ATS`.`vw_sales_consult_attach` AS SELECT `a`.`idprosp_attach` AS `idprosp_attach`, `b`.`prosp_consult_id` AS `prosp_consult_id`, `a`.`idstorage` AS `idstorage`, `c`.`owner_id` AS `owner_id`, `c`.`file_name` AS `file_name`, `c`.`public` AS `public`, `c`.`self_view` AS `self_view`, `c`.`shared` AS `shared`, `c`.`emp_id` AS `emp_id`, `c`.`updated_for_ref_id` AS `updated_for_ref_id`, (CASE WHEN (`c`.`owner_id` = _LATIN1'') THEN 'Admin' WHEN ISNULL(`c`.`owner_id`) THEN 'Admin' ELSE CONCAT(`e`.`firstname`, _LATIN1' ', `e`.`lastname`) END) AS `updater`, `c`.`updated_for_ref_table` AS `updated_for_ref_table`, `a`.`last_updated` AS `last_updated` FROM (((`ATS`.`prosp_attach` `a` LEFT JOIN `ATS`.`storages` `c` ON ((`a`.`idstorage` = `c`.`idstorage`))) LEFT JOIN `ATS`.`emp` `e` ON ((`c`.`owner_id` = `e`.`emp_id`))) LEFT JOIN `ATS`.`prosp_consult` `b` ON ((`a`.`prosp_consult_id` = `b`.`prosp_consult_id`))) ORDER BY `b`.`last_updated` DESC