Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Senior Member jbagley's Avatar
    Join Date
    Sep 2004
    Location
    Cape Town
    Posts
    845
    Member #
    7422
    I want to be able to select say, ONLY the top 10 items in a table. In MSsql I now the command is as follows:
    Code:
    Select top 10 * from table;
    But this sql command doesnt work in mySQL.

    How would I do this mysql? :classic:

  2.  

  3. #2
    WDF Staff Wired's Avatar
    Join Date
    Apr 2003
    Posts
    7,656
    Member #
    1234
    Liked
    137 times
    select * from table limit 10
    The Rules
    Was another WDF member's post helpful? Click the like button below the post.

    Admin at houseofhelp.com

  4. #3
    Senior Member jbagley's Avatar
    Join Date
    Sep 2004
    Location
    Cape Town
    Posts
    845
    Member #
    7422
    Thanks for the help Wired. I knew it was pretty simple.

  5. #4
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    If you want to diplay the whole table content, but in increments of 5 rows at the time (as when diplaying thumbnails from a large photogallery), you can add an offset to LIMIT as well. You can make that dynamic as shown below:

    PHP Code:
    SELECT FROM `table_namelimit 9,5;
    /*
    9 is the offset (meaning it would start from row 10).
    5 is the number of rows to extract. In the above example, rows
    10 through 14 would be extracted.
    */

    #######

    //Dynamically:
    //You can add an iterator to your code and replace the offset number
    //with a variable, to extract all data in sections (in this case 10)
    SELECT FROM `table_namelimit $i,10
    S. Rosland


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:19 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com