I am new to the forum and have not programmed for a long time, so please tell me if this was the wrong approach method.
Usage: The user searches for a partial zip code, such as "RG20", which then needs to be displayed in a specific order. The query uses the MATCH AGAINST method in boolean mode, where an example of a zip code in a database is βRG20 7TTβ so that it can find it. At the same time, it also matches the list of other postal codes that are in it with a radius (which is a separate request).
Problem: I cannot find a way to sort by partial match, for example:
ORDER BY FIELD(postcode, 'RG20', 'RG14', 'RG18','RG17','RG28','OX12','OX11') DESC, city DESC
Since he is not specifically looking for the RG20 7TT, I do not think he can make a partial match. I tried SUBSTR (zip code, -4) and looked left and right, but I did not manage to use the "field" and could not find another route ... Sorry, this is a little longer, but I'm a little bit attached. The UK zip code is broken into 2 parts, the last section is always 3 characters, and in my database there is a space between them, if that helps at all. Thank you in advance.
EDIT: although there is DESC after the zip codes, I need them to appear in that particular order (RG20, RG14, then RG18, etc.). I am not sure if specifying downstream remove the order or not.