[thelist] MySQL Inserts
rudy
r937 at interlog.com
Wed Jan 29 06:42:02 CST 2003
> ... if I am creating an item to insert into both Items and ItemClor
because
> the auto_increment has not been created and assigned and inserted into
> ItemID it can't be simultaneously inserted into another table because the
> record doesn't exist? Is that right?
that's correct
if ItemID is the auto_increment column, leave it out of the INSERT statement
insert
into Items
( ItemSKU
, ItemName
, ItemDescription
, ItemCost
, Category
, ShippingCost )
values
( '$ItemSKU'
, '$ItemName'
, '$ItemDescription'
, '$ItemCost'
, '$Category'
, '$ShippingCost'
, '$ItemID' )
then use mysql_insert_id to get the value that was assigned to ItemID
then use this value when inserting into the other table
> this realtional database stuff suppposed to be this easy?
yes, very easy, especially after you work your way through a basic tutorial
;o)
More information about the thelist
mailing list