Jump to content

Need help with creating logic for searching table


jordanwb

Recommended Posts

I'm making a jukebox and I want the user to be able to search the songs in the database by it's name. What I want to do is get all the songs whose name contains any of the words in the search term. I found out you can use Regex in a sense:

 

SELECT * FROM `box_songs` WHERE `song_name` REGEXP 'Convoy'

 

 

What I'd like to do is sort the result by the number of matches between the search terms and the songs in the database, most matches first. I was thinking of getting all the records which contains any of the words in the search terms then using substr_count and add up all the occurances then sorting. That would work but it may be slow and a bubble sort would be inefficient.

 

Thanks.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.