jordanwb Posted March 19, 2008 Share Posted March 19, 2008 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.