Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save masterofthesith/ce1e9b9c21d144f2a550a77744e1e31d to your computer and use it in GitHub Desktop.
Save masterofthesith/ce1e9b9c21d144f2a550a77744e1e31d to your computer and use it in GitHub Desktop.
Mysql'de arama yaparken birebir eşleşen sonucun en önde gelmesi
#Birebir eşleşenin en önde gelmesi
select * from tablo where field LIKE '%query%' order by (field = 'query'), length(field)
#Eşleşme sırasına göre birebir eşleşenden daha aza doğru sonuçların gelmesi
select * from tablo where field LIKE '%query%' order by (field like 'query%'), length(field)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment