Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT article_id, title, coincidence FROM
- (SELECT article_id,
- COUNT(article_id) as coincidence FROM
- (SELECT t2.article_id, t2.tag_id FROM articles as t1
- JOIN tags_to_articles as t2
- ON tag_id IN
- (SELECT t2.tag_id from articles as t2
- JOIN tags_to_articles as t3
- ON t2.id = t3.article_id
- WHERE t1.id = 1)
- WHERE t2.article_id != 1) t4
- JOIN articles on articles.id = t4.article_id
- GROUP BY article_id) t5
- JOIN articles as t6 on t6.id = article_id
- ORDER BY coincidence DESC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement