Results 1 to 2 of 2

Thread: problem with paged record output

  1. #1
    Join Date
    Jul 2003
    Posts
    1

    Angry problem with paged record output

    I am fetching a large number of records from a table, i want to display 20 records per page. how do i do it. anyone tell me pleazzzzzzzz.......

  2. #2
    Join Date
    Feb 2003
    Location
    Johannesburg, South Africa
    Posts
    145
    Which OS are you using? On *nix you can logon with the standard mysql client and then do:

    Code:
    mysql> \P /usr/bin/less
    PAGER set to /usr/bin/less
    If you now execute a query ( SHOW STATUS for example ) the output will be piped to /usr/bin/less and you can page through the info as usual.

    Not to sure how this would work under Windows though

    PS: I assume you are refering to the mysql client pager function here. Please correct me if I'm wrong.

    If you are refering to limit the output, you can append the following to your SQL:

    Code:
    ... LIMIT 0,20
    Please refer to the MySQL online documentation which states:

    The LIMIT clause can be used to constrain the number of rows returned by the SELECT statement. LIMIT takes one or two numeric arguments, which must be integer constants. With one argument, the value specifies the number of rows to return from the beginning of the result set. With two arguments, the first specifies the offset of the first row to return, the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1): To be compatible with PostgreSQL MySQL also supports the syntax: LIMIT row_count OFFSET offset.

    mysql> SELECT * FROM table LIMIT 5,10; # Retrieve rows 6-15

    To retrieve all rows from a certain offset up to the end of the result set, you can use -1 for the second parameter:

    mysql> SELECT * FROM table LIMIT 95,-1; # Retrieve rows 96-last.

    If one argument is given, it indicates the maximum number of rows to return:

    mysql> SELECT * FROM table LIMIT 5; # Retrieve first 5 rows

    In other words, LIMIT n is equivalent to LIMIT 0,n.
    I hope this answers your question

    Cheers

Posting Permissions

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