我想这样做:

Quantity   Price    Payment
1           12      12.00

这是我的代码:
CREATE DEFINER=`root`@`localhost`
PROCEDURE `insertproducts`
(
    pname varchar(50),
    pdesc varchar(50),
    psupp varchar(50),
    pdate date,
    pquant int,
    pprice double
)
begin
insert into products
(
    prodname,
    proddescription,
    prodsupplier,
    proddate,
    prodquantity,
    prodprice,
    prodpayment
)
values
(
    pname,
    pdesc,
    psupp,
    pdate,
    pquant,
    pprice,
    ppayment
)
set prodpayment = pprice * prodquantity;
end

这不管用,知道吗?

最佳答案

什么是ppayment?你可以直接乘以参数,

insert into products
(
    prodname,
    proddescription,
    prodsupplier,
    proddate,
    prodquantity,
    prodprice,
    prodpayment
)
values
(
    pname,
    pdesc,
    psupp,
    pdate,
    pquant,
    pprice,
    pprice*prodquantity
)

09-27 10:40