Guest User

Untitled

a guest
Dec 13th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.48 KB | None | 0 0
  1. +-------------------+--------------+------+-----+---------+----------------+
  2. | Field | Type | Null | Key | Default | Extra |
  3. +-------------------+--------------+------+-----+---------+----------------+
  4. | id | int(11) | NO | PRI | NULL | auto_increment |
  5. | post_id | int(11) | YES | | NULL | |
  6. | post_title | varchar(200) | YES | | NULL | |
  7. | post_date | int(11) | YES | | NULL | |
  8. | post_featured_img | varchar(200) | YES | | NULL | |
  9. | post_scope | int(11) | YES | | 0 | |
  10. +-------------------+--------------+------+-----+---------+----------------+
  11.  
  12. +------------------+------------+------+-----+---------+-------+
  13. | Field | Type | Null | Key | Default | Extra |
  14. +------------------+------------+------+-----+---------+-------+
  15. | post_id | int(11) | NO | PRI | NULL | |
  16. | post_likes_count | bigint(20) | NO | | 0 | |
  17. +------------------+------------+------+-----+---------+-------+
  18.  
  19. post_descriptions:
  20. | Field | Type | Null | Key | Default | Extra |
  21. +------------------+--------------+------+-----+---------+-------+
  22. | post_id | int(11) | NO | PRI | NULL | |
  23. | post_description | longtext | NO | | NULL | |
  24. | post_link | varchar(200) | NO | | NULL | |
  25. +------------------+--------------+------+-----+---------+-------+
  26.  
  27. +---------+---------+------+-----+---------+----------------+
  28. | Field | Type | Null | Key | Default | Extra |
  29. +---------+---------+------+-----+---------+----------------+
  30. | id | int(11) | NO | PRI | NULL | auto_increment |
  31. | user_id | int(11) | NO | | NULL | |
  32. | post_id | int(11) | NO | | NULL | |
  33. +---------+---------+------+-----+---------+----------------+
  34.  
  35. +---------+-------------+------+-----+---------+----------------+
  36. | Field | Type | Null | Key | Default | Extra |
  37. +---------+-------------+------+-----+---------+----------------+
  38. | id | int(11) | NO | PRI | NULL | auto_increment |
  39. | user_id | varchar(45) | NO | | NULL | |
  40. | post_id | varchar(45) | NO | | NULL | |
  41. +---------+-------------+------+-----+---------+----------------+
  42.  
  43. SELECT post_feeds.post_id
  44. ,post_feeds.post_title
  45. ,post_feeds.post_date
  46. ,post_feeds.post_featured_img AS post_featured_image
  47. ,ifnull(post_likes.post_likes_count ,0) AS post_likes_count
  48. ,(user_post_likes.post_id IS NOT NULL) AS post_liked
  49. ,post_descriptions.post_description
  50. ,post_descriptions.post_link
  51. FROM cloneposts_base.post_feeds
  52. LEFT JOIN cloneusers_base.user_post_bookmarks
  53. ON user_post_bookmarks.post_id = post_feeds.post_id
  54. AND user_post_bookmarks.user_id = 1
  55. LEFT JOIN cloneposts_base.post_likes
  56. ON post_likes.post_id = post_feeds.post_id
  57. LEFT JOIN cloneusers_base.user_post_likes
  58. ON user_post_likes.post_id = post_feeds.post_id
  59. AND user_post_likes.user_id = 1
  60. LEFT JOIN cloneposts_base.post_descriptions
  61. ON post_descriptions.post_id = post_feeds.post_id
  62. WHERE post_feeds.post_date<unix_timestamp()
  63. AND (post_scope=0 OR post_scope=1)
  64. ORDER BY
  65. post_feeds.post_date DESC limit 10
Add Comment
Please, Sign In to add comment