Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2010

    Unanswered: WinSQL Lite - Retrieving top N rows


    I'm a novice user and cannot retrieve the first 5 or 10 rows from a database table. Please help. I'm using WinSql.
    Last edited by m_spogter; 10-06-10 at 02:56. Reason: Poor spelling

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    so create your query
    set an appropriate ORDER BY clause
    and use LIMIT X where X is the number of rows to reutrn

    so thats
    SELECT my,column,list FROM mytable
    WHERE acondition evaluates as true /*such as ColumnA < 9.37 */
    ORDER BY a,column,list
    LIMIT 5

    MySQL :: MySQL 5.1 Reference Manual :: 12.2.8 SELECT Syntax

    bear in mind that databases have no concept of the first or last or whatever records unless you specify an order. the data is stuffed into a table and will be retrieved depending on some criteria the db decides (that may be the primary key, that may be the last index used, it may be the phase of the moon)
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Oct 2010


    THanks, it worked!!!

Posting Permissions

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