Reputation: 598
I am trying to do something like
INSERT INTO tbl_order_detail (key_order,key_product,fld_unit_price,fld_quantity)
VALUES (<value1>, <value2>,
SELECT fld_unit_price,fld_quantity FROM tbl_product WHERE key_product = <value2>);
What is the proper syntax for this?
Upvotes: 0
Views: 189
Reputation: 1168
INSERT
INTO tbl_order_detail
(
key_order,
key_product,
fld_unit_price,
fld_quantity
)
SELECT
<value1>,
<value2>,
fld_unit_price,
fld_quantity
FROM tbl_product
WHERE key_product = <value2>
;
Upvotes: 1
Reputation: 7181
INSERT INTO tbl_order_detail
(key_order,key_product,fld_unit_price,fld_quantity)
SELECT <value1>, <value2>, fld_unit_price,fld_quantity
FROM tbl_product
WHERE key_product = <value2>;
Upvotes: 5