Dave Rigby wrote:
> Hi,
>
> Could you create a linked list of the links- i.e. have a 'Next' field,
> which contains the ID of the next URL in order. You will also need a
> field to store if the link is the first (i.e. root) of the list. Then
> you can just iterate though the rows, using the next field to tell you
> which URL is next. To add or delete will only require one or two changes
>
> It might be a bit overkill if the list of URLs is quite small, but it
> will scale up to any size
Errmm... every now and then someone will say "linked list"
in this forum. Now, everybody, repeat after me:
SQL is NOT suited for linked lists. SQL is about thinking
in SETs of data. If you need linked lists, there's a thousand
languages more suited for the purpose.
Now, returning to the original question:
Hold on to the idea of a precedence field, then add a
DATETIME field "precedence_changed", where you note
the last time the precence was set.
Then, whenever you query the data:
ORDER BY precedence, precedence_changed DESC
That will give you the records in order of precedence,
placing the more recently "proceeded" records first.
The solution and its effects may require a bit of
explanation to the customer, tho'
/ Carsten
--
Carsten H. Pedersen
keeper and maintainer of the bitbybit.dk MySQL FAQ
http://www.bitbybit.dk/mysqlfaq
>
> Regards
>
>
> On 07 Aug 2001 02:35:26 -0600, Healthwell.com wrote:
> >
> > I have a general "how do you do that" SQL question.
> >
> > I have a table with links in it. One link per row, with URL
> link name, etc.
> >
> > The client wants to be able to specify the order in which the
> links appear.
> > In other words, they want to set any link to show up first,
> another other
> > link to show up second, etc, etc.
> >
> > I did a rough think like this a while back, by allowing then to set a
> > "precedent" field, than the sorted on that field. The trick
> is, of course,
> > if they ad a link and want it to show up in the second slot, then the
> > "precedence" filed for records higher then 2 need to be
> incremented by one,
> > so the sequence will still be in tack.
> >
> > I'm thinking there must be a better way to do this, but I don't
> know what it
> > is.
> >
> > Thanks in advance,
> >
> > Peter Janett
> >
> > New Media One Web Services
> > ================================
> > WEB HOSTING FOR WEB DEVELOPERS
> > ================================
> > Sun, IRIX, Windows 2000, Linux;
> > PHP, MySQL, Perl, Cold Fusion,
> > MS SQL, ASP, SSI, SSL
> > http://www.newmediaone.net
> > [EMAIL PROTECTED]
> > (303)828-9882
> >
> >
> >
> > ---------------------------------------------------------------------
> > Before posting, please check:
> > http://www.mysql.com/manual.php (the manual)
> > http://lists.mysql.com/ (the list archive)
> >
> > To request this thread, e-mail <[EMAIL PROTECTED]>
> > To unsubscribe, e-mail
> <[EMAIL PROTECTED]>
> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> >
> --
> Dave Rigby
>
> Opal Telecom
>
> ---------------------------------------------------------------------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail <[EMAIL PROTECTED]>
> To unsubscribe, e-mail
> <[EMAIL PROTECTED]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php