What you think? What will be the best option to search related videos in mysql videos table with matching title+tags+description?

Very easy Idea!

# SELECT * FROM `videos` WHERE title LIKE ‘%$title%’ OR tags LIKE ‘%$tags%’ OR description LIKE ‘%$description';

Full-text Search is a feature introduced to MySQL in version 3.23.23.

You have to add key in videos table for title+tags+description….

# ALTER TABLE `videos` ADD FULLTEXT(`title`,`tags`,`description`);

# SELECT *, MATCH(`title`,`tags`,`description`) AGAINST (“‘.$search_string.'”) as Relevance FROM `videos` WHERE MATCH (`title`,`tags`,`description`) AGAINST(“‘.$search_string.'” IN BOOLEAN MODE) ORDER BY `Relevance` DESC;

# SELECT * FROM `videos` WHERE MATCH (`title`,`tags`,`description`)
AGAINST (‘+myspace -youtube’ IN BOOLEAN MODE);

These SQL will return result automatically sorted by relevancy.

3 Responses to MySQL Related Search (title+tags+description)

  1. Anonymous says:

    Hey! Just wanted to depart a comment. I truly enjoyed this article. Continue the awesome effort.

  2. Anonymous says:

    Hi I discovered this website by mistake after i was searching yahoo just for this issue, I need to say your website is really helpful I also love the theme, its amazing!. I dont have a whole lot time to read your entire post at this time but I’ve got bookmarked it and also signed up for your RSS feeds. I will be in a week or so. appreciate your a fantastic site.

  3. Anonymous says:

    Kudos for posting this kind of useful weblog. Your website isn’t only informative and also very artistic too. There tend to be very several people that can write not too simple articles that creatively. Maintain the favorable writing !!

Leave a Reply