Re: FN-FORUM: Mysql syntax help
date posted 1st May 2008 17:43
On Thu, 2008-05-01 at 17:19 +0000, Dom Latter wrote:
> On Thursday 01 May 2008 18:37:17 Graham Stark wrote:
>
> > Is id always greater for later entries? (You'd get that if you had set
> > the autoincrement attribute on that field). If so then you'd get what
>
> I think it's possible for MySQL to re-use deleted ID values.
Sort of.. If (as seems to be the case here) the primary key field is an
integer with autoincrement set, it will always ascend, so if the current
highest id is 3, and you delete id=3, then the next id will be 4. You
could replace a deleted row manually, however, (insert ... where id =
3). Mysql behaves differently with composite keys, however, as I
understand it, and perhaps in clusters.
> Even if
> not, relying on what is basically a side-effect isn't going to be a good
> idea.
>
What's the alternative? There's no timestamp field there, so far as I
can see, so you can't pick the entry that's actually the latest, if for
some reason the ID fields are mixed up. And, in this case, the ids
won't be mixed up, provided they are not being set manually.
Graham
--
Graham Stark, Virtual Worlds, http://www.virtual-worlds.biz
Phone (+44) 01908 618239 Mobile (+44) 07952633185 Skype graham_k_stark