MYSQL Wildcards Search – Sort Result Issue

问题内容:

I have a table of chemicals in mysql database. I would like to perform a wildcards search like –

SELECT * FROM chemical where chemical like ‘%toluene%’

SQL query result is –

Bromotoluene
Chlorotoluene (Benzyl chloride)

Cymene (Isopropyltoluene)

Dinitrotoluene (DNT)

Isopropyl toluene (Cymene)

Octachlorotoluene

Toluene (Toluol)*

Toluene di-isocyanide (TDI)

Trinitrotoluene (TNT)

Can results with exact matches from the first character of the string (in this case, ‘toluene’) be listed ahead of any other result? For example – I would like to display –
Toluene (Toluol) AND Toluene di-isocyanide (TDI) first and then rest of the results.

Many thanks for your help.

问题评论:

    
use only %toluene

原文地址:

https://stackoverflow.com/questions/47756745/mysql-wildcards-search-sort-result-issue

Tags:,

添加评论