I want to find records in which some STARTS WITH field with some string (let them say "ar") OR this field CONTAINs the string "ar".
However, I believe that the two conditions are different from each other, because I limit the number of results returned to 10, and I want the STARTS WITH state to be weighted more heavily than the CONTAINS condition.
Example:
SELECT * FROM Employees WHERE Name LIKE 'ar%' OR Name LIKE '%ar%' LIMIT 10
The trap is that if there are names that start with "ar", they must be approved. The only way to return a name that simply CONTAINS "ar" is if there are less than 10 names that START with "ar"
How to do this for a MySQL database?
sql mysql where
Stephen stchur
source share