Advertisement
Guest User

Untitled

a guest
Sep 21st, 2016
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.47 KB | None | 0 0
  1. SELECT article_id, title, coincidence FROM
  2. (SELECT article_id,
  3.        COUNT(article_id) as coincidence FROM
  4. (SELECT t2.article_id, t2.tag_id FROM articles as t1
  5. JOIN tags_to_articles as t2
  6. ON tag_id IN
  7. (SELECT t2.tag_id from articles as t2
  8. JOIN tags_to_articles as t3
  9. ON t2.id = t3.article_id
  10. WHERE t1.id = 1)
  11. WHERE t2.article_id != 1) t4
  12. JOIN articles on articles.id = t4.article_id
  13. GROUP BY article_id) t5
  14. JOIN articles as t6 on t6.id = article_id
  15. ORDER BY coincidence DESC
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement