Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [MySQL]wykorzystywanie "Limit"
Forum PHP.pl > Forum > Przedszkole
olszam
Mam pytanko jak mam np. zapytanie
  1. SELECT * FROM `konta` LIMIT 0 , 30
tzn że minimum wyników wyświetli się 0 a maksimum 30, a jak bym miał np. 21, 41 to od 21 rekordu by mi się wyświetliło do 41, jeśli dobrze to rozumiem. Pytam dla pewności bo w ogóle nie korzystałem z tej klauzuli od swojego początku z mysql i php.
abort
A że tak zapytam... Manuala czytał?

Kod
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 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.

olszam
jam nie czaić taki angielski tylko polski rozumieć i z polskich tutków się uczyć smile.gif
17misiek09
  1. SELECT * FROM tbl LIMIT 30;

wyswietli pierwszych 30 rekordow

  1. SELECT * FROM tbl LIMIT 1,10;

wyswietli rekordy od 2-11

  1. SELECT * FROM tbl LIMIT 95,123123131232;

wyswietli rekordy od 95 do ostatniego

hmm a Tobie brakuje ;
na to wyglada
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.