ng949 (3/20/2008)
Hi,I am trying to write a SQL statement to find related videos in a video site for a particular video. The TAG terms under a video goes as a query to this SQL statement to find related videos. Following SQL statement returns only the same video (single video) that has the exact tags. How do I change this to find all videos that has any word of the TAG string. Thanks. Norman
SELECT TOP 20 * FROM Videos WHERE isEnabled=1 AND isPrivate=0
AND title like '%Music Video Classic 80s %'
OR description like '%Music Video Classic 80s %'
OR tags like '%Music Video Classic 80s %'
ORDER BY date_added DESC
You should SPLIT the string and it will looks like:
SELECT TOP 20 * FROM Videos WHERE isEnabled=1 AND isPrivate=0
AND title like '%Music Video Classic 80s %'
OR description like '%Music Video Classic 80s %'
OR tags like '%Music%'
OR tags like '%Video%'
OR tags like '%Classic%'
OR tags like '%80s%'
ORDER BY date_added DESC
I think you can get my idea.
Cheers,
Gonzalo