top of page
Search

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.

11 views0 comments

Recent Posts

See All

According to a survey conducted, nearly 63% programmers mentioned that they will likely continue to work with Java along with coding with Python, SQL and HTML/CSS. In addition, the giants in the corpo

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

Uploading quite a lot of rows of data from a text, csv, and excel file into a MySQL table is a repetitive task for sysadmins and DBAs who are handling MySQL database. This blog clarifies 4 applied exa

bottom of page