Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [MySQL]wykorzystywanie "Limit"
olszam
post
Post #1





Grupa: Zarejestrowani
Postów: 342
Pomógł: 23
Dołączył: 20.01.2011
Skąd: Chełm

Ostrzeżenie: (0%)
-----


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.
Go to the top of the page
+Quote Post
abort
post
Post #2





Grupa: Zarejestrowani
Postów: 590
Pomógł: 107
Dołączył: 25.10.2011

Ostrzeżenie: (0%)
-----


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.

Go to the top of the page
+Quote Post
olszam
post
Post #3





Grupa: Zarejestrowani
Postów: 342
Pomógł: 23
Dołączył: 20.01.2011
Skąd: Chełm

Ostrzeżenie: (0%)
-----


jam nie czaić taki angielski tylko polski rozumieć i z polskich tutków się uczyć (IMG:style_emoticons/default/smile.gif)

Ten post edytował olszam 15.09.2012, 23:37:35
Go to the top of the page
+Quote Post
17misiek09
post
Post #4





Grupa: Zarejestrowani
Postów: 137
Pomógł: 8
Dołączył: 16.12.2011
Skąd: Kraków

Ostrzeżenie: (0%)
-----


  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

Ten post edytował 17misiek09 16.09.2012, 00:58:20
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 25.12.2025 - 13:01