This question has already been answered:
There are two tables
I fulfill request
SELECT p.image FROM oc_product p WHERE product_id = '31' UNION (SELECT pim.image FROM oc_product_image pim WHERE product_id = '31' ORDER BY `sort_order` ASC) Those. sorting in the second query does not work, or it works, but in the query it still displays the unsorted

UNION ALLinstead of simpleUNION- Yaant