SELECT
webshop_products.*,
IF((SELECT `wp`.`expected_delivery_date` FROM `webshop_purchase_items` AS purchase_items
LEFT JOIN `webshop_purchase` AS wp ON purchase_items.purchase_id = wp.id
WHERE purchase_items.product_identifier_id = webshop_products.identifier_id AND wp.completed = '0' AND purchase_items.product_variant_id = 0
ORDER BY `wp`.`expected_delivery_date` ASC LIMIT 0,1) IS NOT NULL,
(SELECT `wp`.`expected_delivery_date` FROM `webshop_purchase_items` AS purchase_items
LEFT JOIN `webshop_purchase` AS wp ON purchase_items.purchase_id = wp.id
WHERE purchase_items.product_identifier_id = webshop_products.identifier_id AND wp.completed = '0' AND purchase_items.product_variant_id = 0
ORDER BY `wp`.`expected_delivery_date` ASC LIMIT 0,1),
webshop_products.expected_delivery_date
) AS expected_delivery_date,
webshop_products.id AS id,
i.name AS pri_image,
pi.id AS pri_image_id,
i2.name AS hover_image,
pi2.id AS hover_image_id,
wu.name AS unit_name,
sl.external_location,
wo.name AS category1_name,
IF((SELECT id FROM `webshop_product_composed` WHERE produkt_identifier_id=webshop_products.identifier_id LIMIT 1), 1, 0) AS is_composed_master_product,
(SELECT GROUP_CONCAT(tag_id SEPARATOR ',') FROM `webshop_product_tags` WHERE `product_id`=webshop_products.identifier_id) AS tags_id
FROM `webshop_products`
LEFT JOIN `webshop_options` AS wo ON `webshop_products`.`category1` = `wo`.`id`
LEFT JOIN `webshop_units` AS wu ON webshop_products.unit_id=wu.id
LEFT JOIN `webshop_product_images` AS pi ON webshop_products.identifier_id=pi.product_id AND pi.primary_img='1'
LEFT JOIN `webshop_product_images` AS pi2 ON webshop_products.identifier_id=pi2.product_id AND pi2.is_hover_image='1'
LEFT JOIN `webshop_stock_locations` AS sl ON sl.id=webshop_products.stock_location_id
LEFT JOIN `images` AS i ON pi.image_id=i.id
LEFT JOIN `images` AS i2 ON pi2.image_id=i2.id
/*
LEFT JOIN `webshop_product_composed` AS wpc ON wpc.produkt_identifier_id=webshop_products.identifier_id
*/
WHERE `webshop_products`.`hide`!=1 AND (`webshop_products`.`hide_language` != 1 AND `webshop_products`.language_id = 5) AND `language_id`=5 AND `category1` IN('1423','1421') AND `category2` IN('1561') GROUP BY webshop_products.identifier_id ORDER BY DESC
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 'DESC' at line 48