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.

8 views0 comments

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

Upload Data to MySQL tables using mysqlimport

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

Backup Databases With mysqldump Tool

In this blog, you will study how to use mysqldump tool back up MySQL databases. MySQL GUI tools such as phpMyAdmin, SQLyog and etc, normally deliver features for backup MySQL databases with ease. But,

Call

T: +44 7825018241

Follow me

 

© 2020 by GoplarDB 

All Rights Reserved

Powered by: Goplar LTD

  • LinkedIn Social Icon
  • Twitter Clean