SELECT m.sgr_department_code , IF(m.sgr_machine_short_desc_vi <> '', m.sgr_machine_short_desc_vi,m.sgr_machine_short_desc) , m.sgr_machine_type_code -- , m.marketing_description , mt.sgr_machine_type_desc_vi as sgr_machine_type_desc , m.sgr_machine_brand , trim(concat(m.sgr_machine_model,' ',sgr_machine_submodel)) as sgr_machine_model , m.sgr_machine_year , m.sgr_machine_ID , m.marketing_status as status , u.url_name_vi as url_name , mt.Miscellaneous , (select url_image from TMBR_WEB_URLS where url_action = 'SEARCH' and url_name like 'BD-%' and url_brand = m.sgr_machine_brand order by url_count desc limit 1) url_image , (UPPER( concat_ws(' ',m.sgr_machine_ID,UPPER(m.sgr_machine_short_desc), UPPER(mt.sgr_machine_type_desc_vi), UPPER(m.sgr_machine_brand),UPPER(m.sgr_machine_model),UPPER(m.sgr_machine_submodel), UPPER(m.marketing_description),m.sgr_machine_year) ) ) as concatenacion FROM TMBR_WEB_MACHINES as m , TMBR_WEB_MACHINE_TYPES mt , TMBR_WEB_DEPARTMENTS d , TMBR_WEB_URLS u WHERE d.sgr_department_code = m.sgr_department_code and mt.sgr_machine_type = m.sgr_machine_type_code and u.url_name Like 'R-%' and u.url_action = 'SPEC' and u.url_dept = m.sgr_department_code and u.url_m_type = m.sgr_machine_type_code and u.url_ref = m.sgr_machine_ID -- AND m.sgr_department_code = 'TP' -- AND m.sgr_machine_type_code = 'TPSE' AND m.web_published = '1' AND upper(m.sgr_machine_brand) = ucase(?) ORDER BY concat(m.sgr_machine_brand,m.sgr_machine_model,sgr_machine_submodel) ASC , sgr_machine_ID DESC LIMIT 0, 18