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 sorting' at line 4
SELECT DISTINCT optionID FROM SC_categories_top_options_in_product WHERE categoryID = ORDER BY sorting