Error message: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ') ORDER BY priority DESC' at line 31
SELECT t1.*, t1.id as product_id, t2.brand_name, t2.brand_website, t3.unit_name, DATE_FORMAT(t1.created, '%d.%m.%Y') as created2, IF(t1.name_et != '', t1.name_et, t1.name_et) as name, IF(t1.description_et != '', t1.description_et, t1.description_et) as description, IF(t1.url_code_et != '', t1.url_code_et, t1.url_code_et) as url_code, IF(price_discount > 0 AND price_discount < price, price_discount, price) as current_price, IF(price_discount > 0 AND price_discount < price, 1, 0) as is_discounted, ( SELECT fk_category_id FROM mdl_shop_product_category AS pc JOIN mdl_shop_categories AS c ON pc.fk_category_id = c.id WHERE fk_product_id = t1.id AND c.lang_code = 'et' ORDER BY fk_category_id DESC LIMIT 1 ) AS main_cat_id, ( SELECT COUNT(*) FROM mdl_shop_product_files WHERE type='image' AND fk_product_id = t1.id LIMIT 1 ) AS images_count FROM mdl_shop_products AS t1 LEFT JOIN mdl_shop_brands AS t2 ON t1.fk_brand_id = t2.id LEFT JOIN mdl_shop_units AS t3 ON t1.fk_unit_id = t3.id WHERE t1.active = 1 AND t1.deleted = 0 AND name_et != '' AND t1.id NOT IN() ORDER BY priority DESC