🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: be.comp.programming
Article #4244

Re: [(my)SQL] records selecteren uit database

#4244
From: Tim Van Wassenhove
Date: Mon, 08 Sep 2003 11:10
55 lines
3647 bytes
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

In article <pan.2003.09.08.11.01.00.394628@no-spam-pandora.be.invalid>, Robby De Smedt wrote:
> Op Mon, 08 Sep 2003 08:59:46 +0000, schreef Passero:
> 
>> 
>> "Robby De Smedt" <rods@no-spam-pandora.be.invalid> schreef in bericht
>> news:pan.2003.09.08.08.50.10.788089@no-spam-pandora.be.invalid...
>>> Op Mon, 08 Sep 2003 08:44:12 +0000, schreef Passero:
>>>
>>> > Onlangs heb ik op een nieuwsgroep gelezen dat zo iets mogelijk:
>>> > select top 3 * from  tabel order by ......
>>> >
>>> > Nu is mijn vraag, bestaat zo iets ook voor records die ergens in het
>> midden
>>> > liggen zodat je een bereik kan ingeven? 
> 
><knip>
>>> Normaal kan je daar toch limit voor gebruiken:
>>>
>>>  SELECT * FROM `top_3` LIMIT 0, 30
>>> zal record 0 tot 30 tonen
>> 
>> dus als ik dan schrijf: SELECT * from tabel LIMIT 501,500  dan werkt dat?
> 
> Neen want 500 is kleiner dan 501. Het 2de getal moet groter zijn maar dat
> zal wel aan een typfout liggen denk ik 
>==> SELECT * from tabel LIMIT 501, 550 zou wel moeten werken.


Jawel hoor, dat werkt... Dat geeft dan de rijen 501 tot 501+500 uit de resultset.

van http://www.mysql.com/doc/en/SELECT.html
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


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE/XGPCoCDYcHc9TmoRAnDdAJ9oaZC5Z46ZsQ6mnMJ8hWDsDDF1egCfcPoj
eFuE8SOaAGmj1t95eQwKyjI=
=X1nJ
-----END PGP SIGNATURE-----

-- 
Visit my website at http://aardbei.madoka.be
Technical Details
Message-ID: <bjho43$irefn$1@ID-188825.news.uni-berlin.de>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!madoka.isw.student.khleuven.BE!not-for-mail
References: <wjX6b.8133$7u6.359523@phobos.telenet-ops.be> <pan.2003.09.08.08.50.10.788089@no-spam-pandora.be.invalid> <6yX6b.8154$3u6.358463@phobos.telenet-ops.be> <pan.2003.09.08.11.01.00.394628@no-spam-pandora.be.invalid>

Show Full Headers
Complete Article Headers
X-Google-Language: DUTCH,ASCII-7-bit
X-Google-Thread: 107324,f15c1c5c73ca25c7
X-Google-Attributes: gid107324,public
X-Google-Thread: fcea4,f15c1c5c73ca25c7
X-Google-Attributes: gidfcea4,public
X-Google-ArrivalTime: 2003-09-08 04:11:14 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-01!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!fu-berlin.de!uni-berlin.de!madoka.isw.student.khleuven.BE!not-for-mail
From: Tim Van Wassenhove <euki@pi.be>
Newsgroups: be.comp.programming,nl.comp.programmeren
Subject: Re: [(my)SQL] records selecteren uit database
Followup-To: be.comp.programming
Date: 8 Sep 2003 11:10:59 GMT
Lines: 55
Message-ID: <bjho43$irefn$1@ID-188825.news.uni-berlin.de>
References: <wjX6b.8133$7u6.359523@phobos.telenet-ops.be> <pan.2003.09.08.08.50.10.788089@no-spam-pandora.be.invalid> <6yX6b.8154$3u6.358463@phobos.telenet-ops.be> <pan.2003.09.08.11.01.00.394628@no-spam-pandora.be.invalid>
NNTP-Posting-Host: madoka.isw.student.khleuven.be (193.190.138.70)
X-Trace: news.uni-berlin.de 1063019459 19773943 193.190.138.70 (16 [188825])
X-PGP-KeyID: 0x773D4E6A
User-Agent: slrn/0.9.7.4 (Linux)