We have a table with a list of posts (over 10,000), each entry has a Title, ID and other fields. We would like to display 5 related posts, based on the keywords of the selected title. What would be the most efficient method in the MySQL syntax to extract 5 related posts? LIKE? MATCH? I'm new to this so any help would be very much appreciated.
Well I'd suggest you using something like this: SELECT * FROM `[COLOR="Red"]table_name[/COLOR]` WHERE `[COLOR="Red"]title_field[/COLOR]` LIKE '%[COLOR="Red"]$keyword[/COLOR]%' LIMIT 0 , 5 Code (markup): Let me know if this is what you wants.
I am already aware of this syntax, however simply using that will not work... for example... SELECT * FROM `table_name` WHERE `title_field` LIKE '%This is a test post%' LIMIT 0 , 5 Code (markup): Will only return the single post with the title "This is a test post"! I want to be able to return 5 related posts from the keywords in the title of the record selected. Thank you for your help.
Yes, I could enable the title field for a fulltext search. Using PHP, how would I get the results I need? Would I need to break up each word from the title before feeding it into a MySQL full text search? Or could I simply run a MATCH on the full title? Any help would be great, I'm very new to this! Thank you.