I have a that takes the tags of a current video and matches them with other videos for results. The only issue is I would like to exclude the video that the tags are from开发者_如何转开发 (exclude a specific vid_id). I tried the following but the line AND vid_id!=some_id
breaks it. Any ideas?
$sql = "SELECT video.*,COUNT(*) as count FROM tags LEFT JOIN video
ON (tags.vid_id = video.vid_id)
WHERE name IN(?,?) AND vid_id!=some_id
GROUP BY vid_id ORDER BY count DESC LIMIT 5";
Did you forget to close the parenthesis after the ON clause?
Also, since your vid_id column is present both in the video table and in the tags table, you'll need to specify the tablename in the WHERE-clause (yes, even though the ON-statement requires they be equal)
That gives:
$sql = "SELECT video.*,COUNT(*) as count
FROM tags
LEFT JOIN video
ON (tags.vid_id = video.vid_id)
WHERE name IN(?,?)
AND video.vid_id != some_id
ORDER BY count DESC
LIMIT 5";
精彩评论