How to create auto suggest using MySQL

Now a days most of the web sites want to use their data and want to suggest end user suggestion based on that data while they are typing in the text field. Problem we face when we use like clause of the MySQL query and try to fetch the relevant words but like clause will only fetch the exact matching words not the relevant or close words. To address this issue, I have tried to use soundex of MySQL for creating the auto suggest for typing. Here is the stored procedure which can check for the relevant word in the table and then suggest the correct word.

Here is the country table and data which I have used in this example.

I have created small html file (index.html) and php file (request.php) for calling the required MySQL function call.

Now create the index.html file and paste the following code in it for checking the auto suggest MySQL function call.

You can copy paste the code into the respective files and put then under Apache server /var/www/html folder. Now you can test the auto suggest for the countries if you type the wrong name for the country it will suggest the correct name for it.

Now you can use this example and implement it on your table data.


Recent Posts

See All

Deleting Duplicate Rows in MySQL

In this blog, you will study several ways to delete duplicate rows in MySQL. In this blog, I have shown you how to find duplicate values in a table. Once the duplicates rows are recognized, you may ne


T: +44 7825018241

Follow me


© 2020 by GoplarDB 

All Rights Reserved

Powered by: Goplar LTD

  • LinkedIn Social Icon
  • Twitter Clean