Note that there are some explanatory texts on larger screens.

plurals
  1. POGet next 10 batch of info after a certin ID mySQL query?
    primarykey
    data
    text
    <p>I am creating a trending feed of videos for an iPhone app and am calculating all of the views on a video in the last 24 hours in a views table (a row is added to the views table everytime it is views and has a timestamp and videoid). When I do infinite scrolling for it I send back the count of the last video views and I use the HAVING statement in mySQL to get the next videos </p> <p><code>"HAVING COUNT(views.videoid) &lt; 'count of views'" with a "LIMIT 10"</code> at the end to select 10 at at time.</p> <p>This works, however if a video has the same number of views as another video in the last 24 hours then that video could get skipped because it is a &lt; statement. And if I use a &lt;= statement videos will show up multiple times. </p> <p>Is there a way that I could select videos after a videoid after the </p> <pre><code>"ORDER BY COUNT(views.videoid) DESC" </code></pre> <p>to get the next video in line? Probably not but does anyone know how I would go about doing that. Here is my query.</p> <pre><code>SELECT f.userid, f.username, video.videoid, video.videolink, video.timestamp, video.caption, video.tags, video.address, video.likecount, video.commentcount, video.viewcount, video.shareid, CASE WHEN liketable.likekey &gt; 0 THEN 1 ELSE 0 END AS didlike, COUNT(views.videoid) AS trendcount FROM user AS f RIGHT JOIN video ON video.userid = f.userid LEFT JOIN user ON user.token = ? LEFT JOIN liketable ON liketable.videoid = video.videoid AND liketable.userid = user.userid RIGHT JOIN views ON views.videoid = video.videoid WHERE views.timestamp &gt; ? GROUP BY video.videoid HAVING COUNT(views.videoid) &lt; ? ORDER BY COUNT(views.videoid) DESC LIMIT 10 </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload