>-----Original Message----- >From: João Cândido de Souza Neto [mailto:j...@consultorweb.cnt.br] >Sent: Friday, January 21, 2011 12:47 PM >To: mysql@lists.mysql.com >Subject: Re: CURRENT insert ID > >Ok, you must have your own reasons to do that. > >The fact is: You can´t set the auto_incremente value field to another field >in the same table and record even in a trigger. > >So, the best way is a second update. > [JS] That's what I'm trying to do now, but I'm using MS Access through an ODBC connection and I haven't figured out how to retrieve last_insert_id.
I should ask in the myodbc forum. Regards, Jerry Schwartz Global Information Incorporated 195 Farmington Ave. Farmington, CT 06032 860.674.8796 / FAX: 860.674.8341 E-mail: je...@gii.co.jp Web site: www.the-infoshop.com >-- >João Cândido de Souza Neto > >"Darryle Steplight" <dstepli...@gmail.com> escreveu na mensagem >news:AANLkTim+fjYUoU+1A5RG9eFS+NnaZXT7K+Ho-q=f-...@mail.gmail.com... >@Joao - I'm currently building a database out right now that has this >scenario. One field can be the primary key, that has a purpose for holding >the record id, another field can hold the value. Let say there are two >fields, id, s_id. Initially, you insert a record and `id` is now 100 and you >update s_id to be 100. But for whatever reason, later down the road you >need s_id to be 200. You can just update the s_id field instead of deleting >the entire record and inserting an entire new one with X amount of fields. >Updating one field is a lot less work than deleting and inserting. I have my >tables set up so I won't have to use the primary key for queries, I will >only use the s_id field. > >2011/1/21 João Cândido de Souza Neto <j...@consultorweb.cnt.br> > >> I can´t think about how useful for you would be to have two fields with >> the >> same value. >> >> -- >> João Cândido de Souza Neto >> >> ""Jerry Schwartz"" <je...@gii.co.jp> escreveu na mensagem >> news:007501cbb98a$177acba0$467062e0$@co.jp... >> Here it is in a nutshell: >> >> >> >> I have a field that needs to be set equal to the auto-increment ID as a >> record is entered. I don't know how to do this without a subsequent UPDATE >> (which I can do with a trigger). Is there any way to avoid the cost of an >> UPDATE? >> >> >> >> Here's a more concrete description of the problem: >> >> >> >> CREATE TABLE t ( >> >> id INT(11) AUTO-INCREMENT PRIMARY, >> >> xxx INT(11) >> >> ); >> >> >> >> When a record is added to table `t`, I need to set `xxx` to the value >> generated for `id`. (`xxx` might be changed later.) >> >> >> >> Is there anything clever I can do? >> >> >> >> Regards, >> >> >> >> Jerry Schwartz >> >> Global Information Incorporated >> >> 195 Farmington Ave. >> >> Farmington, CT 06032 >> >> >> >> 860.674.8796 / FAX: 860.674.8341 >> >> E-mail: <mailto:je...@gii.co.jp> je...@gii.co.jp >> >> Web site: <http://www.the-infoshop.com/> www.the-infoshop.com >> >> >> >> >> >> >> -- >> MySQL General Mailing List >> For list archives: http://lists.mysql.com/mysql >> To unsubscribe: http://lists.mysql.com/mysql?unsub=dstepli...@gmail.com >> >> > > >-- >---------------------------------------------- >"May the Source be with you." > > > >-- >MySQL General Mailing List >For list archives: http://lists.mysql.com/mysql >To unsubscribe: http://lists.mysql.com/mysql?unsub=je...@gii.co.jp -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/mysql?unsub=arch...@jab.org