elfs: (Default)
[personal profile] elfs
Oh, mightly LJ brain, riddle me this:

I have a table in a MySQL (well, okay, it's Sqlite3 right now, but it'll my MySQL in production) database, and the primary keys are known to not be contiguous. That's important.

It's possible to construct a WHERE clause giving you a single item, if that items qualties are unique enough. Is it possible, using some magic combination of WHERE and ORDER BY and something I don't know, to say "give me unique item N, and using the rule of the ORDER BY clause, also give me the next and previous objects?"

Date: 2009-09-30 07:55 pm (UTC)
From: [identity profile] shockwave77598.livejournal.com
Why not have additional fields that hold the keys for the previous and next items? A database implementation of a linked list.

Date: 2009-09-30 08:16 pm (UTC)
From: [identity profile] elfs.livejournal.com
Insertions may be random. It might be worth contemplating, but it makes insertions expensive.

Profile

elfs: (Default)
Elf Sternberg

June 2025

S M T W T F S
1234567
891011121314
15161718192021
22232425262728
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 1st, 2025 02:27 pm
Powered by Dreamwidth Studios