I have a query like this:
SELECT products.* FROM products WHERE products.code = 'search word' OR products.id IN(SELECT product_names.product_id FROM product_names WHERE MATCH (product_names.name) AGAINST ('+search* +word*' IN BOOLEAN MODE) ORDER BY product_names.sorting_field) ORDER BY ???
I want the order of the main request to be the same as the order with WHERE IN() . I canβt use FIELD or FIND_IN_SET because I donβt know what I get from MATCH AGAINST .
I tried things like ORDER BY FIELD(products.id, product_names.product_id) , etc., but I did not understand how to make it work.
In fact, my query is much longer and more complex, it is somewhat pseudo version. I cannot do MATCH AGAINST outside of a subquery.
unska source share