我想知道,在mysql中,如何将一列数据从一个表复制到另一个表,同时插入更多的值。
表1:
**id:**1
**Items :**[{"id":"9","size":"64 GB","quantity":"1"},{"id":"9","size":"32 GB","quantity":2},{"id":"1","size":"32","quantity":"1"},{"id":"5","size":"8","quantity":"1"},{"id":"2","size":"38","quantity":"1"}]
**Create_Date:**31/08/2018
**Exp_date:**01/09/2018
表2:
**id:**
**Order_id:**
**Items:**
**Paid:**
我想复制表1的项目,并插入它表2,同时我想插入订单号,支付表2
为此,我正在尝试:
$order_id = "DJ9JQY4J00248";
$paid = "Order Complete";
$insertSql = "INSERT INTO table2 (`order_id`,`paid`) VALUES ('$order_id','$paid') AND (items) SELECT items FROM cart WHERE id = '{$cart_id}'";
$db->query($insertSql);
请指出我做错了什么。上面的代码不适合我。
1条答案
按热度按时间7z5jn7bk1#
您可以移动变量以选择