我建议
insert . . . select改用:
insert into test.products_per_order (Orders_idOrders, Products_idProducts, Price, Quantity) select x.idOrder, x.idProduct, p.price, x.qty from (select 1 as idOrder, 2 as idProduct, 5 as qty union all select 1 as idOrder, 2 as idProduct, 4 as qty union all . . . -- I've left these out so you can see the structure of the query select 3 as idOrder, 3 as idProduct, 9 as qty ) x left join test.products p on p.idProducts = x.idProduct;
这使得错字导致错误价格的可能性大大降低。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)