Code:
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SUBSTRING( vpc.`customfield_params` , LOCATE('product_tags="', vpc.`cust' at line 7 SQL=SELECT DISTINCT(vpl.`virtuemart_product_id`) , vpl.`product_name` , vpl.`product_s_desc` , vp.`virtuemart_vendor_id` , vp.`product_special`, vcl.`category_name` , vcl.`virtuemart_category_id` , vm.`file_url` , vm.`file_url_thumb` , vpc.`customfield_params` AS stored_tags , vpp.`product_price`,vpp.`product_tax_id`, vpp.`product_discount_id`,vpp.`override`,vpp.`product_override_price` SUBSTRING( vpc.`customfield_params` , LOCATE('product_tags="', vpc.`customfield_params` )+14 , CHAR_LENGTH( vpc.`customfield_params` ) - ( LOCATE('"|', REVERSE( vpc.`customfield_params` ) ) +2 ) - 14 ) AS accented_tags FROM `#__virtuemart_products_fa_ir` vpl JOIN `#__virtuemart_products` vp ON vpl.`virtuemart_product_id` = vp.`virtuemart_product_id` JOIN `#__virtuemart_product_customfields` vpc ON vpl.`virtuemart_product_id` = vpc.`virtuemart_product_id` JOIN `#__virtuemart_product_categories` vpcat ON vpcat.`virtuemart_product_id` = vp.`virtuemart_product_id` JOIN `#__virtuemart_categories_fa_ir` vcl ON vcl.`virtuemart_category_id` = vpcat.`virtuemart_category_id` LEFT JOIN `#__virtuemart_product_medias` vpm ON vpl.`virtuemart_product_id` = vpm.`virtuemart_product_id` AND (vpm.ordering='0' OR vpm.ordering='1') LEFT JOIN `#__virtuemart_medias` vm ON vm.`virtuemart_media_id` = vpm.`virtuemart_media_id` AND SUBSTR( vm.file_mimetype , 1 ,6 ) = 'image/' AND vm.published='1' LEFT JOIN #__virtuemart_product_prices vpp ON vpl.virtuemart_product_id = vpp.virtuemart_product_id WHERE vp.`published`='1' AND vpc.`customfield_value`='vm2tags' GROUP BY vpl.`virtuemart_product_id` HAVING ( (accented_tags LIKE LOWER('%,,%') OR accented_tags LIKE LOWER(',%') OR accented_tags LIKE LOWER('%,') OR accented_tags LIKE LOWER('') )) ORDER BY vp.`product_special` DESC, vp.`virtuemart_product_id` DESC