SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: easy question

  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2002
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    easy question

    ok this is an easy question but i don't know how to answer it

    this is my code, this code will read everything i have in my data base and spit out a char of the top 20 music videos (rating+ the number they show up is counter) and we get an everage..
    now this does it for all the database
    i wanna limit it to read only 500 rows from the tables not the whole thing,, just the most 500 recent reviews and do the calculations on them,, so how can u do that,.. thanks in advance

    $rs = new MySQLPagedResultSet("SELECT Album_ID, Artist_ID, SUM(Rating) AS sumratings from Reviews where MediaType='$MusicType' GROUP BY Album_ID ORDER BY sumratings DESC LIMIT 20",20, $cnx);?>

  2. #2
    With More ! for your $ maxor's Avatar
    Join Date
    Feb 2004
    Location
    Scottsdale, Arizona
    Posts
    909
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What does your

    Code:
    LIMIT 20",20,$cnx
    Refer to?

    You could LIMIT 500 to show only 500 records, however that would only show the top 500 records according to 'sumratings' (which you have in your ORDER BY statement).

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2002
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    LIMIT 20",20, $cnx

    refers to results u wanna show,, do u wanna show the top 10 or top 20 most popular results from the WHOLE database,,
    so what i mean trying to do is to show the top 20 most popular results from the latest most recent 500 reviews on my website,, and if u change the limit to 500 that doesn't change anything,,

  4. #4
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    It would be easier to add another WHERE clause to say that the reviews are more recent than a certain date, than to try to only look at the last 500.. I'm not sure how that's possible in a single query.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •