|
我创建了以下简单的代码datamodel:& t z7 C7 E; h- ~. `* @

' q7 m& E9 Y$ Y5 k0 U: x我使用以下代码insert statements来插入值:# T9 v* |* K+ U& u) f
1)餐桌 产品 :
& F2 G+ r1 g1 i8 mINSERT INTO test.products(ProductName,Price)VALUES (" roduct A","99,99"),(" roduct B","49,95"),(" roduct C","5,95");2)表格 顺序 :- \; M# }* K: _- W7 C4 k
INSERT INTO test.orders(Customer)VALUES ("Customer A"),("Customer B"),("Customer B");到目前为止,所有这些工作都很正常。
( Y: j2 U' O9 ]但是,现在我也想table中插入值Products_per_Order。
; [, D* [. }7 q% T& k! i如您datamodel在Products_per_Order表格中看到的列包含Price。我想插入这个专栏的参考价格 ID
: C$ m" T. L: } I列Products_idProducts。因此,我尝试使用以下方法,insert statement但到目前为止还没有正常工作:+ F4 t, Z6 [+ X, H* s
INSERT INTO test.products_per_order(Orders_idOrders,Products_idProducts,Price,Quantity)VALUES("1","1",(Select Price from test.products),"5"),("1","2",(Select Price from test.products),"4"),("2","1",(Select Price from test.products),"10"),("3","2",(Select Price from test.products),"3"),("3","3",(Select Price from test.products),"9");你有解决这个问题的想法吗?
* x/ I$ H0 W" ]& I2 ~* ~ ; T* {5 s2 v4 ^* }7 t
解决方案: |
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?立即注册
x
|