我可以像这样在我的数据库中复制一行:
INSERT into `product` (productCode, title, description, price, productGroup)
SELECT productCode, title, description, price, productGroup
FROM `product`
WHERE productCode = $_GET['id']
但我希望productCode
与我复制的行具有不同的值。我希望它是:$productCode
我该怎么做?
答案 0 :(得分:0)
您可以根据需要更改产品代码值
INSERT into `product` (productCode, title, description, price, productGroup)
SELECT 'your product code value' AS productCode, title, description, price, productGroup
FROM `product`
WHERE productCode = ".$_GET['id']
答案 1 :(得分:0)
您可以将其添加到insert
:
INSERT into `product` (productCode, title, description, price, productGroup)
SELECT $productCode, title, description, price, productGroup
FROM `product`
WHERE productCode = $_GET['id'];
如果您从应用程序代码中调用此参数,我建议您使用此参数和id
。
答案 2 :(得分:0)
这将有效:
INSERT into `product` ($productCode, title, description, price, productGroup)
SELECT productCode, title, description, price, productGroup
FROM `product`
WHERE productCode = $_GET['id']
答案 3 :(得分:0)
INSERT into `product` (productCode, title, description, price, productGroup)
SELECT $productCode, title, description, price, productGroup
FROM `product` p
WHERE p.productCode = $_GET['id'];
答案 4 :(得分:0)
$ _ GET ['id']必须在字符串中。用'或'
包装id'INSERT into product (productCode, title, description, price, productGroup) SELECT'.$productCode.', title, description, price, productGroup FROM product WHERE productCode = "'.$_GET['id'].'"';
答案 5 :(得分:-1)
这样做:
INSERT into `product` (productCode, title, description, price, productGroup)
SELECT "$productCode", title, description, price, productGroup
FROM `product`
WHERE productCode = ".$_GET['id']