Thanks every one who replied

Sorry for posting that question here.

Miguel thanks for putting me on the right track with this .. i couldn't get
it to work with mysql_insert_id() but looking that up it basically said that
this one works better LAST_INSERT_ID()  but I wouldn't have found that if
you didn't put me in the right direction so thank :)

Cheers

Peter

-----Original Message-----
From: Miguel Cruz [mailto:[EMAIL PROTECTED]]
Sent: Monday, 13 May 2002 1:40 PM
To: Peter
Cc: Php
Subject: Re: [PHP] inserting data to mutliple mysql tables


This is a MySQL question, not a PHP question.

Anyway, with MySQL you can't do this as a single operation. Do your
inserts one after the other.  You can use mysql_insert_id() after each one
to get the value of an auto_increment field that was created, and feed
that into your next SQL statement.

miguel

On Mon, 13 May 2002, Peter wrote:
> I have a table that's full of references to indexs in other tables if I
want
> to insert a new record do I have to make a script to insert into all the
> tables ie:
>
> insert script for table 1
> insert script for table 2
> insert script for table 3
> insert script for table 4
>
> or can I have it all in one insert statement like you can with the SELECT
> statement ie
>
> INSERT INTO table1, table2, table3, table4 (blah, blah1, blah2, blah3,
> blah4, blah5) VALUES('$blah', '$blah1', '$blah2', '$blah3', '$blah4',
> '$blah5');
>
>
> and if i can do it that way how do i get the table referencing the indexes
> to show the reference number rather than the actual inputted data ie: say
> table1 is the reference table and table 2 is the table that matches up the
> username with the real name where i want the actual full information to be
> stored.
>
> eg table 1
>
> id userid
> 1 10
>
> table 2
>
> id username nameid
> 10 boo 15
>
> table 3
>
> id name extra fields in here
> 15 bob Smith
>
> now when i add a new record I want table one to be have the new userid
added
> to it table 2 to have the full user name matched to their nameid inserted
> and table 3 to get the full name of the person...
>
> any ideas?
>
> Cheers
>
> Peter
> "the only dumb question is the one that wasn't asked"
>
>
>
>


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to