Hirdetés

Új hozzászólás Aktív témák

  • Sk8erPeter

    nagyúr

    válasz modder #8967 üzenetére

    Érdekesség, hogy ez a szintaxis a PostgreSQL-lel való kompatibilitás miatt került bele:
    SELECT Syntax - LIMIT clause
    "For compatibility with PostgreSQL, MySQL also supports the LIMIT row_count OFFSET offset syntax."

    Egyébként:

    "LIMIT takes one or two numeric arguments, which must both be nonnegative integer constants (except when using prepared statements).

    With two arguments, the first argument specifies the offset of the first row to return, and the second specifies the maximum number of rows to return. The offset of the initial row is 0 (not 1):

    SELECT * FROM tbl 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 some large number for the second parameter. This statement retrieves all rows from the 96th row to the last:

    SELECT * FROM tbl LIMIT 95,18446744073709551615;
    With one argument, the value specifies the number of rows to return from the beginning of the result set:

    SELECT * FROM tbl LIMIT 5; # Retrieve first 5 rows
    In other words, LIMIT row_count is equivalent to LIMIT 0, row_count."

    A phpMyAdmin is utóbbi szintaxist használja.
    Persze teljesen jó az említett OFFSET-et tartalmazó szintaxis, meg talán kifejezőbb is a query általa, de említésre méltó az idézett változat is, hátha valaki azt ismeri jobban - MySQL query-knél én utóbbit gyakrabban szoktam látni kész kódokban (nyilván a másikra is bőven akad példa).

Új hozzászólás Aktív témák