Re: grabbing id from new record
| From: | Unknown Sender | Date: | Mon, 14 Jan 2002 14:43:15 +0000 |
| Subject: | Re: grabbing id from new record | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-15770@lists.php.net to get a copy of this message | ||
Hi.
What about Auto_increemnt field ??
Your's id can be auto_increment field. for example:
create table dupencja (id int(7) auto_increment not null, primary key(id));
so when you insert records:
insert into dupencja values('') - > id will be 1
insert into dupencja values('') - > id will be 2
this is auto_increment, so your trick isn't need.
More in manula of mysql.
regards.
I piasecki - www.b-c.pl
----- Original Message -----
From: "George Pitcher" <fmdev@yahoo.co.uk>
To: <php-db@lists.php.net>
Sent: Monday, January 14, 2002 3:23 PM
Subject: [PHP-DB] grabbing id from new record
> Hi,
>
> Is there a way to grab the ID (from ID field) while INSERTing a new
record?
>
> I am currently doing a separate INSERT then a SELECT query to find the
most
> recently added record by that user:
>
> select ID from table where user = '$user' order by ID DESC limit 0,1
>
> This does the trick but it may not be the most efficient way.
>
> George
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.307 / Virus Database: 168 - Release Date: 11/12/01
>
>
> _________________________________________________________
> Do You Yahoo!?
> Get your free @yahoo.com address at http://mail.yahoo.com
>
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net
> For additional commands, e-mail: php-db-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
--
Znudzilo Ci sie logo w komorce?
Wgraj nowe [ http://komorki.onet.pl/dodatki.html ]