On Fri, Jun 08, 2001 at 12:43:16AM +0100, Jorge Oliveira wrote:
> Hi,
> 
> I have two tables in my database:
> 
> #TB1
>   ID_tb1 (auto-incremented)
>   ID_tb2
>   name
>   address
> 
> #TB2
>   ID_tb2 (auto-incremented)
>   method
>   status
> 
> I need to run a query that inserts values into #TB1 and #TB2, having
> #TB1.ID_tb2 equal to #TB2.ID_tb2.
> 
> Since #TB2.ID_tb2 is auto incremented, I don't know how to get the same
> value inserted at #TB1.ID_tb2...

Sounds like you need to insert into TB2 first.  Then retrieve the value
of ID_tb2.  If you're using the perl DBI, I believe it's in
$sth->{'mysql_insertid'} (see perldoc DBD::mysql).  Finally, do your
insert into TB1.

-- 
Maurice Aubrey <[EMAIL PROTECTED]>

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to