从搜索框中获取内容,在数据库中查找内容

I know this is a broad question, but seriously.. I really couldnt find and answer for this, only the LIKE keyword that checks if it contains it..

I want to look for something in a db if it contains it, starts with it, or ends with it and by order by the most populaur result?

I have a search box in bootstrap and when the content is changed, an ajax request is sent for the new content..

It there a way to do this.

Using LIKE is nothing. Use full text search in mysql. There are disadvantages: myisam required, for char/varchar/text fields only. See more info here: https://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html

A great alternative is using a real search engine such as Elasticsearch, built on the top of Apache Lucene: fast, relevant, flexible, adaptable, works with json api. See more info here: https://www.elastic.co/products/elasticsearch