🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: chile.comp.programacion
Article #2921

Re: Obtener ID despues de una insercion (PHP+MySQL)

#2921
From: RobertoCL
Date: Wed, 20 Jul 2005 21:21
15 lines
1576 bytes
"Chano" <jgarrido@dcc.uchile.NOSPAM.cl> escribi� en el mensaje 
news:dbm61n$rdd$5@localhost.localdomain...
>  Necesito insertar datos en una tabla, que tiene un campo ID integer con 
> autoincremento.
> Al insertar los datos, me gustar�a poder recuperar el ID del campo 
> insertado, de manera
> de poder usarlo en otras tablas. Hay forma de recuperarlo sin tener que 
> realizar
> otra consulta?
http://cl.php.net/manual/es/function.mysql-insert-id.php en php
o LAST_INSERT_ID() en mysql
INSERT INTO a VALUES(NULL,"now()");
INSERT INTO b VALUES(NULL,LAST_INSERT_ID(),"a");
--
RCL 
Technical Details
Message-ID: <dbmf50$7t7$1@proxy.ifxnw.cl>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!nntp-server.pubsub.com!news1.nivel5.cl!news2.ifxnw.cl!not-for-mail
References: <dbm61n$rdd$5@localhost.localdomain>

Show Full Headers
Complete Article Headers
X-Google-Thread: 1593cb,6e6fc2fd18ca8644
X-Google-Attributes: gid1593cb,public
X-Google-Language: SPANISH,ASCII
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!nntp-server.pubsub.com!news1.nivel5.cl!news2.ifxnw.cl!not-for-mail
From: "RobertoCL" <rcl2020NOSPAM@hotmail.com>
Newsgroups: chile.comp.programacion
Subject: Re: Obtener ID despues de una insercion (PHP+MySQL)
Date: Wed, 20 Jul 2005 17:21:37 -0400
Organization: IFX Networks News Server
Lines: 17
Message-ID: <dbmf50$7t7$1@proxy.ifxnw.cl>
References: <dbm61n$rdd$5@localhost.localdomain>
NNTP-Posting-Host: 200.73.30.63
X-Trace: proxy.ifxnw.cl 1121894368 8103 200.73.30.63 (20 Jul 2005 21:19:28 GMT)
X-Complaints-To: abuse@ifxnetworks.com
NNTP-Posting-Date: Wed, 20 Jul 2005 21:19:28 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2527
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2527
X-RFC2646: Format=Flowed; Original