Re: CURRENT insert ID

2011-01-24 Thread Jaime Crespo Rincón
2011/1/21 Jerry Schwartz : >>-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 you

Re: CURRENT insert ID

2011-01-24 Thread Mark Goodge
On 24/01/2011 15:42, Jerry Schwartz wrote: -Original Message- From: Donovan Brooke [mailto:li...@euca.us] Sent: Friday, January 21, 2011 7:28 PM Cc: mysql@lists.mysql.com Subject: Re: CURRENT insert ID Just an idear.. Don't auto_increment the main table.. create a unique Id

RE: CURRENT insert ID

2011-01-24 Thread Jerry Schwartz
>-Original Message- >From: Donovan Brooke [mailto:li...@euca.us] >Sent: Friday, January 21, 2011 7:28 PM >Cc: mysql@lists.mysql.com >Subject: Re: CURRENT insert ID > >Just an idear.. > >Don't auto_increment the main table.. create a unique Id table, >

RE: CURRENT insert ID

2011-01-24 Thread Jerry Schwartz
Cc: 'mysql.' >Subject: Re: CURRENT insert ID > >Seeing from later posts that you're using InnoDB, why don't you simply >wrap the INSERT/UPDATE into a transaction? You don't avoid the UPDATE, >but I'm not sure I understand the need to mess w/ triggers. >

Re: CURRENT insert ID

2011-01-23 Thread Carsten Pedersen
ehr... Den 23-01-2011 15:36, Carsten Pedersen skrev: Seeing from later posts that you're using InnoDB, why don't you simply wrap the INSERT/UPDATE into a transaction? You don't avoid the UPDATE, but I'm not sure I understand the need to mess w/ triggers. BEGIN INSERT INTO t(id) NULL UPDATE t SE

Re: CURRENT insert ID

2011-01-23 Thread Carsten Pedersen
Seeing from later posts that you're using InnoDB, why don't you simply wrap the INSERT/UPDATE into a transaction? You don't avoid the UPDATE, but I'm not sure I understand the need to mess w/ triggers. BEGIN INSERT INTO t(id) NULL UPDATE t SET xxx=last_insert_id() COMMIT Best, / Carsten Den

Re: CURRENT insert ID

2011-01-21 Thread Jesper Wisborg Krogh
Hi, On 22/01/2011, at 11:27 AM, Donovan Brooke wrote: > Just an idear.. > > Don't auto_increment the main table.. create a unique Id table, > auto_increment that, and grab that value first for use with both fields in > your main table. This can be wrapped into a trigger, so the main table fun

Re: CURRENT insert ID

2011-01-21 Thread Donovan Brooke
Just an idear.. Don't auto_increment the main table.. create a unique Id table, auto_increment that, and grab that value first for use with both fields in your main table. Donovan -- D Brooke -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:h

RE: CURRENT insert ID

2011-01-21 Thread Jerry Schwartz
>-Original Message- >From: Michael Dykman [mailto:mdyk...@gmail.com] >Sent: Friday, January 21, 2011 1:27 PM >To: Jerry Schwartz >Cc: MySql >Subject: Re: CURRENT insert ID > >You don't need to do an update: > >... > >new.xxx = new.id >... >

RE: CURRENT insert ID

2011-01-21 Thread Jerry Schwartz
>-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

Re: CURRENT insert ID

2011-01-21 Thread Michael Dykman
; 'MySql' >>Subject: RE: CURRENT insert ID >> >>>-Original Message- >>>From: Michael Dykman [mailto:mdyk...@gmail.com] >>>Sent: Friday, January 21, 2011 11:50 AM >>>To: MySql >>>Subject: Re: CURRENT insert ID >>> &g

Re: CURRENT insert ID

2011-01-21 Thread Jo�o C�ndido de Souza Neto
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. -- João Cândido de Souza Neto "Darryle Steplight" escreveu na mensagem news:AANL

Re: CURRENT insert ID

2011-01-21 Thread Darryle Steplight
@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

Re: CURRENT insert ID

2011-01-21 Thread Jo�o C�ndido de Souza Neto
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"" 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-inc

RE: CURRENT insert ID

2011-01-21 Thread Jerry Schwartz
I made a typo in my previous message. >-Original Message- >From: Jerry Schwartz [mailto:je...@gii.co.jp] >Sent: Friday, January 21, 2011 12:20 PM >To: 'Jerry Schwartz'; 'Michael Dykman'; 'MySql' >Subject: RE: CURRENT insert ID > >

RE: CURRENT insert ID

2011-01-21 Thread Jerry Schwartz
>-Original Message- >From: Jerry Schwartz [mailto:je...@gii.co.jp] >Sent: Friday, January 21, 2011 11:56 AM >To: 'Michael Dykman'; 'MySql' >Subject: RE: CURRENT insert ID > >>-Original Message- >>From: Michael Dykman [mailto:mdyk...

RE: CURRENT insert ID

2011-01-21 Thread Jerry Schwartz
>-Original Message- >From: Michael Dykman [mailto:mdyk...@gmail.com] >Sent: Friday, January 21, 2011 11:50 AM >To: MySql >Subject: Re: CURRENT insert ID > >I think an ON INSERT TRIGGER would take care of this; can't think of >any other way. Using last_ins

Re: CURRENT insert ID

2011-01-21 Thread Michael Dykman
I think an ON INSERT TRIGGER would take care of this; can't think of any other way.  Using last_insert_id() in the argument list would likely yield you the previous value (which might not even related to your table. Having siad that..   odd requirement.  - michael dykman ps -- sorry for the