Reputation: 21830
The way I understand it, when MySQL performs a LIKE
query, depending on how you've set up your query (%)string(%)
, the search string looks for exact text matches within your selected content.
I'm curious as to how and if the resulting rows are ordered according to matches found?
For example, if my query LIKE
string 'frankly'
is queried against a table that has the following content:
id content
-------------
1 frankly, i find cake rather delicious
2 frankly, i find cake repulsive, frankly
3 i currently live on franklyn street
Would any particular row be favored over the other?
Upvotes: 1
Views: 369
Reputation: 258
LIKE is a kind of a filter.
Like doesn't really related with sort itself.
If you haven't add any explicit sort, rows are sorted by default(I guess by key).
Upvotes: 0
Reputation: 13097
MySql doesn't guarantee an order for LIKE queries like that. In general, if you want a specific order, you will have to specify it using ORDER BY.
The specific order depends on many other factors, like join-type(Hash-join, Merge-join, etc) and data access method (index-scan, sequential scan, etc).
Upvotes: 5