Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $mostviewed_query = "SELECT p.id, COUNT(v.target) AS number_of_views FROM ".TBL_PROFILES." AS p LEFT JOIN ".TBL_VIEWS." AS v ON (p.id = v.target) WHERE DATE_SUB(NOW(),INTERVAL 7 DAY) >= v.timestamp GROUP BY p.id ORDER BY number_of_views DESC LIMIT 5";
- Above query shows the list:
- Profile 2 - Views: 8
- Profile 3 - Views: 5
- Profile 1 - Views: 4
- Profile 4 - Views: 3
- Profile 5 - Views: 2
- $popular_query = "SELECT p.id, COUNT(v.target) AS number_of_views FROM ".TBL_PROFILES." AS p LEFT JOIN ".TBL_VIEWS." AS v ON (p.id = v.target) LEFT JOIN ".TBL_SLIDES." AS s ON (p.id = s.profile_id) WHERE DATE_SUB(NOW(),INTERVAL 7 DAY) >= v.timestamp GROUP BY p.id ORDER BY number_of_views DESC LIMIT 5";
- Above query shows the list:
- Profile 2 - Views: 8
- Profile 1 - Views: 4
- Profile 4 - Views: 3
- Profile 5 - Views: 2
- Profile 6 - Views: 1
- "Profile 3" has mysteriously disappeared. Even though it should be the same list. All I'm doing in the second query, is to combine TBL_SLIDES table, to get that data.
Add Comment
Please, Sign In to add comment