This sounds pretty complicated when the simple SELECT LAST_INSERT_ID() should work just by itself (and does if you run it from any other program).
I think I'm going to go with: SELECT id FROM tripulatnes ORDER BY id DESC limit 1 That was suggested by mfstuart (thanks for that different approach) as it looks fairly easy to implement. I sure wish that SELECT LAST_INSERT_ID() would work. By the way, I've learned to use "YourSQL" to test out my SQL statements first as testing them in Rev is no fun at all (too many crashes). I think I will experiment with your lock table thing as it sounds interesting, thanks for that suggestion too (I need all the help I can get). Bill On 3/18/05 12:46 PM, "Chris Sheffield" <[EMAIL PROTECTED]> wrote: > Bill, > > I'm no MySQL expert, but I have some code that accomplishes this and it > seems to work just fine. From what I'm seeing in the code I have, it's > necessary to issue a "Lock Table [my table] Write" command, then insert your > record, and then call Last_Insert_ID. After that you have to use Unlock > Tables. > > HTH, > Chris Sheffield > > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Bill > Sent: Friday, March 18, 2005 8:18 AM > To: How to use Revolution > Subject: Re: RunRev crashes when you experiment with database queries > > I tried that command (which is what you use to find the last insert in the > whole database instead of just one table -- the name of the table I'm > dealing with is "tripulantes" which means crewmembers) and it also didn't > work. The command is behaving very strangely as I can run the query over and > over again and it keeps returning a number that it increments by one each > time even though no records have been added in the database. > > > On 3/18/05 11:06 AM, "Gordon Tillman" <[EMAIL PROTECTED]> wrote: > >> Hi Bill, >> >> On Mar 18, 2005, at 08:58, Bill wrote: >> >>> I am trying to get the ID number of the last inserted record in a MySQL >>> database. Can anyone help me do this? >> ... >>> put "SELECT LAST_INSERT_ID() from tripulantes" into dbQuery >>> put revQueryDatabase(tConnection, dbQuery) into LastInsertID >> >> I don't know if this is your problem or not, but I just use SELECT >> LAST_INSERT_ID() as the entire SQL command, omitting the "from..." >> part. I just just my MySQL user manual and I don't see the "from ..." >> as being a valid part of the command, unless maybe you are using a >> newer version than what I have. >> >> --gordy >> >> _______________________________________________ >> use-revolution mailing list >> [email protected] >> http://lists.runrev.com/mailman/listinfo/use-revolution >> >> > > | | | > )_) )_) )_) > )___))___))___)\ > )____)____)_____)\\ > _____|____|____|____\\\__ > -------\ /--------- http://www.bluewatermaritime.com > ^^^^^ ^^^^^^^^^^^^^^^^^^^^^ > ^^^^ ^^^^ ^^^ ^^ > ^^^^ ^^^ > > 24 hour cell: (787) 378-6190 > fax: (787) 809-8426 > > Blue Water Maritime > P.O. Box 91 > Puerto Real, PR 00740 > > > > _______________________________________________ > use-revolution mailing list > [email protected] > http://lists.runrev.com/mailman/listinfo/use-revolution > | | | )_) )_) )_) )___))___))___)\ )____)____)_____)\\ _____|____|____|____\\\__ -------\ /--------- http://www.bluewatermaritime.com ^^^^^ ^^^^^^^^^^^^^^^^^^^^^ ^^^^ ^^^^ ^^^ ^^ ^^^^ ^^^ 24 hour cell: (787) 378-6190 fax: (787) 809-8426 Blue Water Maritime P.O. Box 91 Puerto Real, PR 00740 _______________________________________________ use-revolution mailing list [email protected] http://lists.runrev.com/mailman/listinfo/use-revolution
