SELECT SQL_CALC_FOUND_ROWS t.* FROM( SELECT image.path, (SELECT MAX(timestamp) FROM product_attribute WHERE AND product_attribute.timestamp > 0) AS expires, brand.brand_name AS brand_name, brand.show_on_auckscuba, product.* FROM product JOIN brand ON LEFT JOIN image ON AND image.position=0 WHERE brand.brand_name='molecular-products' AND AND product.status=1 AND brand.show_on_auckscuba=1 AND (product.enable_stock_control=0 OR product.current_stock > 0 OR (product.enable_stock_control=1 AND (product.display_stock_sold=0 OR ( product.display_stock_sold=1 AND product.last_sold > 1540994466 )) ) ) GROUP BY ORDER BY brand.brand_name ASC ) t WHERE t.expires IS NULL OR t.expires > 1542204066 ORDER BY t.product_name ASC, brand.brand_name ASC LIMIT 0,100

Unknown column 'brand.brand_name' in 'order clause'