List:General Discussion« Previous MessageNext Message »
From:Jaime Crespo Rincón Date:January 24 2011 4:24pm
Subject:Re: CURRENT insert ID
View as plain text  
2011/1/21 Jerry Schwartz <jerry@stripped>:
>>-----Original Message-----
>>From: João Cândido de Souza Neto [mailto:joao@stripped]
>>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.
>>
>>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 will tell you a secret. But shhhhhhhhhh. Do not tell anyone:

------8<------8<------8<------8<------8<------8<------8<------8<------8<------8<------8<------
mysql> create table mytable(id int auto_increment primary key, name
varchar(255));
Query OK, 0 rows affected (0.07 sec)

mysql> insert into mytable (name) values ('test data');
Query OK, 1 row affected (0.00 sec)

mysql> select id from mytable where id is null;  -- OMG!!!
+----+
| id |
+----+
|  1 |
+----+
1 row in set (0.00 sec)
------8<------8<------8<------8<------8<------8<------8<------8<------8<------8<------8<------


-- 
Jaime Crespo
MySQL & Java Instructor
Software Developer
Warp Networks
<http://warp.es>
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