www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] Clafification of the LIMIT keyword

  1. #1
    Join Date
    Jul 2007
    Location
    Wisconsin
    Posts
    468

    resolved [RESOLVED] Clafification of the LIMIT keyword

    I have this four-table query:
    PHP Code:
    $query "select v.category_id, c.category_name, sum(v.vote_rank), t.user_submitted, t.toolbox_id, u.name from pten_votes v 
        inner join pten_toolboxes t on v.toolbox_id = t.toolbox_id 
        inner join pten_categories c on v.category_id = c.category_id
        inner join pten_users u on t.user_submitted = u.user_id
        where v.category_id = 
    {$category}
        group by v.toolbox_id
        order by sum(v.vote_rank) desc 
        LIMIT 6"
    ;

    $result mysql_query($query,$link);

    while (
    $votes mysql_fetch_assoc($result)) {
            echo 
    "<tr><td>{$votes['sum(v.vote_rank)']}</td><td>{$votes['name']}</td></tr>\r\n";
        } 
    does the LIMIT 6 only look at the first six rows in the table (of 36 rows)? or only display the first six rows of the compiled dataset based on 'where category_id = X' (of approx 10 rows)?
    Last edited by OctoberWind; 08-05-2009 at 06:34 PM. Reason: O_o Clafification? ... it's been a long day. "Clarification"

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,633
    The latter: the first 6 rows of the total result set that matches the rest of the query criteria, including any ORDER BY results (which would be applied before the LIMIT is applied).
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Jul 2007
    Location
    Wisconsin
    Posts
    468
    excellent!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles