Select inside insert operation fails.
I need to make a SELECT inside an INSERT operation, but it fails everytime with this error message:
Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT original_price FROM oc_original_prices WHERE product_id = '12'
This is my php coding:
Which results into this sql code:
$this->db->query("INSERT INTO " . DB_PREFIX . "order_product SET order_id = '" . (int)$order_id . "', product_id = '" . (int)$product['product_id'] . "', original_price = SELECT original_price FROM ".DB_PREFIX."original_prices WHERE product_id = '" .(int)$product['product_id']."'");
I hope someone can tell me what I need to alter to make the sql work.
INSERT INTO oc_order_product SET order_id = '25', product_id = '12', original_price = SELECT original_price FROM oc_original_prices WHERE product_id = '12'