Skip to content
Advertisement

Mysql how to orderby matching query string with Full-Text Searches MATCH AGAINST

Ex I have table:

Id Name
1  bcd def abc
2  def abc
3  abc

I search by Boolean Full-Text Searches like

SELECT * FROM table WHERE MATCH (name) AGAINST ('abc*' IN BOOLEAN MODE)

how to order by if abc is first of text result order like this:

Id Name
1  abc
2  def abc
3  bcd def abc

if ‘abc’ postion is not a head will be pushed down

Advertisement

Answer

You can use locate():

order by locate('abc', name)
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement