我可以在 PHPMyAdmin 中运行以下查询,但由于某种原因,当我在 PHP 中的 mysql 方法中运行它时出现语法错误:
INSERT INTO product (model, stock_status_id, image, price, date_available, status, date_added, date_modified)
VALUES('SP44152', 5, 'data/products/SP44152-1.jpg', '18.04', '2012-06-18', 1, '2012-06-19 00:31:35', '2012-06-19 00:57:01');
SET @lastid = LAST_INSERT_ID();
INSERT INTO product_description (product_id, language_id, name, Description)
VALUES(@lastid, 1, 'Product item 1', 'Product Description');
INSERT INTO product_reward (product_id, customer_group_id, points)
VALUES(@lastid, 1, 0);
INSERT INTO product_to_category (product_id, category_id)
VALUES(@lastid, 67);
INSERT INTO product_to_store (product_id, store_id) VALUES(@lastid, 0);
我得到的错误代码:
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SET @lastid = LAST_INSERT_ID(); INSERT INTO product_description (product_i' at line 3
我试过删除 ; 从每一行的末尾开始,我尝试删除字段“状态”,因为我知道这也是您可以在 MYSQL 中使用的东西。互联网上似乎没有太多可以帮助确定此原因的内容。
非常欢迎任何反馈。