Jump to content

SQL Search query ideas

silentmelodies

I am developing an SQL Search system for a website. I need some ideas.

The idea is to take the name from the item from the SQL database that looks like this:

"Awesome title of something"

Then strip the spaces.

"Awesometitleofsomething"

And then convert to all lowercase.

"awesometitleofsomething"

And then do a search query for example. "Awesome Title"

 

And do the process again for the query, so it would be:

"awesometitle"

Then compare the database and my search input, and show matches.

"awesometitleofsomething"

Got any more ideas?

Lenovo/IBM ThinkPad T61 Widescreen 15.4" 1680x1050
Intel Core2Duo T8300 2.4GHz | 3GB DDR2 from Hynix | SATA II Patched bios (Middleton) | Samsung EVO 850
Arch Linux | Linux 4.3.X x86_64

Link to comment
Share on other sites

Link to post
Share on other sites

Levenshtein distance is commonly used to find similar strings (or other faster, but similar implementations, but levenshtein is easy to understand and gets the point across). There are also ways to get it into your sql query but of course this is very costly.

 

Also, the way you proposed will be very costly too since you need to perform string operations on each table you want to search. No problem if you are doing a "hobby project", but just know that this will reach it's limitation at some point.

 

If you don't care about performance at all I would highly suggest to have a look at levenshtein in combination with like and %. :)

Link to comment
Share on other sites

Link to post
Share on other sites

Not sure if you're looking more for a solution or more for something to program, but if not the latter, I would suggest looking into MySQL full text search.

15" MBP TB

AMD 5800X | Gigabyte Aorus Master | EVGA 2060 KO Ultra | Define 7 || Blade Server: Intel 3570k | GD65 | Corsair C70 | 13TB

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×