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

Reply via email to