SELECT * FROM ( SELECT content.*, custom_field_value_ourspecials.*, owner_table.usr, owner_table.write, owner_table.delete , IF(ISNULL(published_from),creation_date,published_from) AS publish_date FROM content LEFT JOIN custom_field_value_ourspecials ON custom_field_value_ourspecials.id_content = content.id AND custom_field_value_ourspecials.service = 'website' INNER JOIN content_owner AS owner_table ON custom_field_value_ourspecials.id_content = owner_table.id_content ) AS main WHERE macrocat = 'ourspecials' AND lng = 'en' AND usr = 'luxforsale' AND father = 0 AND status = 1 AND publish_state = 1 ORDER BY publish_date DESC, weight DESC LIMIT 0, 3