我有2个表客户和牛奶,如下所示
客户
customers (cid, name, price);
乳
milk (mid, customer_id, milk_letters, mprice)
我想在[{1}}
中加倍价格和milk_letters
以及store
我正在尝试
mprice where customer_id = cid
答案 0 :(得分:1)
您可以在一个查询而不是2
中执行此操作INSERT INTO milk (customer_id, milk_letters, milk_date, mprice)
SELECT {$cid}, {$milk_letters}, NOW(), customers.price * {$milk_letters}
FROM customers
WHERE customers.cid = {$cid}