"SELECT MAX(id)+1 as lastid FROM table"
(It's not +1 if you already said INSERT etc)

I'm not sure what normalized relations are, but I think this will help
anyway.

--t


----- Original Message ----- 
From: "Siegfried Heintze" <[EMAIL PROTECTED]>
To: "'Perl Beginners'" <beginners@perl.org>
Sent: Monday, April 11, 2005 4:18 PM
Subject: AutoIncrement Database Fields for MySQL and PostGreSQL


> If I use the auto-increment feature for a couple of normalized relations,
> how do I insert into them?
>
> Specifically, when I insert into a relation with the autoincrement feature
> on the primary key, how do I get the value of the index on the newly
created
> row so I can use that the value of a foreign key in another relation?
>
> I'm using DBI for a multithreaded application, sometimes for MySQL and
> sometimes for PostGreSQL. In MSAccess, I know, I can only say SELECT
MAX(ID)
> which does not work well for a multithreaded application.
>
> Thanks,
> Siegfried
>
>
>
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>
>
>



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to