MySQL: Insert into multiple tables in same query with BEGIN&COMMIT

Posted by strc on Stack Overflow See other posts from Stack Overflow or by strc
Published on 2012-09-29T03:34:47Z Indexed on 2012/09/29 3:37 UTC
Read the original article Hit count: 146

Filed under:
|

I want to insert into multiple tables in same query by using BEGIN and COMMIT. It seems the error occur at begin.

here is my SQL command

    BEGIN
    INSERT INTO Product (pName, pBrand, pCategory, pSize, pQuantity, pPrice, pDetail)
        VALUES('$name', '$brand', '$category', '$size', '$quantity', '$price', '$detail')
    INSERT INTO Image (iName, iExt, iSize, pID)
        VALUES('$img_name', '$img_ext', '$img_size', LAST_INSERT_ID());
    COMMIT;

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql