13 messages in com.mysql.lists.javaRe: How does one ...| From | Sent On | Attachments |
|---|---|---|
| Jeff Mathis | 22 Aug 2003 10:06 | |
| Mark Matthews | 22 Aug 2003 13:19 | |
| Jeff Mathis | 22 Aug 2003 13:23 | |
| Mufaddal Khumri | 24 Sep 2003 22:42 | |
| Mufaddal Khumri | 25 Sep 2003 00:00 | |
| Mufaddal Khumri | 25 Sep 2003 01:53 | |
| John Beveridge | 25 Sep 2003 15:16 | |
| Jeff Mathis | 30 Sep 2003 12:27 | |
| Mufaddal Khumri | 08 Oct 2003 21:25 | |
| Mufaddal Khumri | 08 Oct 2003 21:36 | |
| Dirk Hillbrecht | 09 Oct 2003 09:57 | |
| Dirk Hillbrecht | 09 Oct 2003 10:16 | |
| Fouche du Preez | 14 Oct 2003 02:25 |
| Subject: | Re: How does one ...![]() |
|---|---|
| From: | Dirk Hillbrecht (dh...@cantamen.de) |
| Date: | 10/09/2003 10:16:09 AM |
| List: | com.mysql.lists.java |
Hi,
No, I am not making any assumptions on the naturaly order of rows in the table. If i for example i had monkey, banana, oranges, watermelon, grapes in a table XYZ. All i want is starting from offset 3 i want two records ... this would be oranges and watermelon returned (considering monkey being at offset 1). Why would this be "principally impossible" ?
You make the assumption that the data is naturally ordered by insertion position. But this might be false. If your table was monkey, banana, house, oranges, watermelon in the first place, then you delete "house" and insert "grapes" after that, it could settle between banana and orange instead of after watermelon. A simple "select * from table" will get the data in arbitrary order and if you do "select * from table limit x,y" you can in fact get random samples of the table.
On-topic insert: This is really the truth! Once, we got exactly this problem as our java server application cuts long select results into chunks by using the LIMIT clause. Without ORDER part, we sometimes received some rows twice and other never. This resulted in a modification of the querying method checking explicitly whether an ORDER part is in the clause or not. End-of-insert.
If you want to have insertion order, use an insertion timestamp. But are as well off by taking the primary key. It is always ascending, so odering by it will give you insertion order. And the LIMIT clause returns you one exact element of the list. Assuming IDs of 1,2,4,5,9,12,13,14,18,... and you wanting to receive elements 6 and 7 would lead to the query
select ... from table order by ID limit 6,2
You get the elements with the IDs 12 and 13.
Best regards, Dirk (not sure about the on-topic-level of this discussion...)
-- --- Dirk Hillbrecht, cantamen GmbH, Vahrenwalder Str. 7 ----- 30165 Hannover, Tel.: +49/511/9357-840, Fax: +49/511/9357-849 ----- eMail: dh...@cantamen.de, Web: http://www.cantamen.de --- PGP fingerprint: 71D8 A381 2B69 144B DABA 78A5 D398 1792 D270 13D7




