mysql - Search order by query string -


i use following working mysql query:

select nom_appellations appellations nom_appellations '%saint%' limit 8 

and have result :

lussac-saint-emilion montagne-saint-emilion puisseguin-saint-emilion saint-emilion saint-emilion grand cru saint-emilion grand cru classé 

but want order string "saint" pertinence this:

saint-emilion saint-emilion grand cru saint-emilion grand cru classé lussac-saint-emilion montagne-saint-emilion puisseguin-saint-emilion 

how can data order featured string ?

you can first appearance of saint in nom_appellations:

select nom_appellations appellations nom_appellations '%saint%' order locate('saint', lower(nom_appellations)) limit 8; 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -