List:General Discussion« Previous MessageNext Message »
From:Jerry Schwartz Date:January 21 2011 7:56pm
Subject:RE: CURRENT insert ID
View as plain text  
>-----Original Message-----
>Sent: Friday, January 21, 2011 12:47 PM
>To: mysql@stripped
>Subject: Re: CURRENT insert ID
>
>Ok, you must have your own reasons to do that.
>
>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: jerry@stripped
Web site: www.the-infoshop.com



>--
>
>"Darryle Steplight" <dsteplight@stripped> escreveu na mensagem
>news:AANLkTim+fjYUoU+1A5RG9eFS+NnaZXT7K+Ho-q=f-GjM@ style="color:#666">stripped...
>@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.
>
>
>> the
>> same value.
>>
>> --
>>
>> ""Jerry Schwartz"" <jerry@stripped> 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:jerry@stripped> jerry@stripped
>>
>> 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=1
>>
>>
>
>
>--
>----------------------------------------------
>"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=1




Thread
CURRENT insert IDJerry Schwartz21 Jan
  • Re: CURRENT insert IDjoao21 Jan
    • Re: CURRENT insert IDDarryle Steplight21 Jan
  • Re: CURRENT insert IDjoao21 Jan
    • RE: CURRENT insert IDJerry Schwartz21 Jan
      • Re: CURRENT insert IDDonovan Brooke22 Jan
        • Re: CURRENT insert IDJesper Wisborg Krogh22 Jan
        • RE: CURRENT insert IDJerry Schwartz24 Jan
          • Re: CURRENT insert IDMark Goodge24 Jan
      • Re: CURRENT insert IDJaime Crespo Rinc√≥n24 Jan
  • Re: CURRENT insert IDCarsten Pedersen23 Jan
    • Re: CURRENT insert IDCarsten Pedersen23 Jan
    • RE: CURRENT insert IDJerry Schwartz24 Jan
Re: CURRENT insert IDMichael Dykman21 Jan
  • RE: CURRENT insert IDJerry Schwartz21 Jan
    • RE: CURRENT insert IDJerry Schwartz21 Jan
      • RE: CURRENT insert IDJerry Schwartz21 Jan
      • Re: CURRENT insert IDMichael Dykman21 Jan
        • RE: CURRENT insert IDJerry Schwartz21 Jan