> What I need to know at the moment (simplified syntax, without all Perl
subtilities) :

>INSERT INTO Country (Name, Continent) VALUES ('France', 'Europe');
>SELECT Country.Id FROM Country WHERE Name='France' AND Continent='Europe';
>INSERT INTO City (Name, CountryId) VALUES ('Paris', Country.Id);

>As you can see, to get the Id which have been affected to the Country that
I
>added, I need to make a SELECT query. But since my first INSERT query only
>nsert one row, I was wondering if I could remove the SELECT statement, and
>just get the Id (choosen by MySQL) as a result of the INSERT query
   I see now your point. If you are using MySQL, you can try
 $sth->{insertid} to check the last autoincrement value inserted by MySQL.
Check
 http://www.mysql.com/doc/P/e/Perl_DBI_Class.html for more details.

> That's it ! Thank you very much !
>
> Thomas

Reply via email to