in reply to SQL Troubles

The other way is to have yet another field. When you create the new row with insert, set this field to a random number. then immediately to a SELECT id WHERE random=3598793457 or whatever the number was.

Works for any database.

____________________
Jeremy
I didn't believe in evil until I dated it.

Replies are listed 'Best First'.
Re: Re: SQL Troubles
by runrig (Abbot) on Dec 01, 2001 at 20:13 UTC
    That'll work 99.999...9 % of the time. But it's that 0.000...1% of the time that'll get ya (i.e. I wouldn't do this with critical data).
      Hmmm. Not following you. When will it not work? If you are referring to the chance of getting two identical random numbers at the same time, use 50 character strings. Use 100 character strings. And then combine them with the date, time, the phase of the moon and your pid. Date + time + pid alone should be enough, though.

      ____________________
      Jeremy
      I didn't believe in evil until I dated it.