0
insert into recharge (user_id, package_id, recharge_date, expiry_date)
values ('datta_vcc','mb02','2013-06-06',
           new.recharge_date+((select validity from internet_package where
           internet_package.package_id=new.package_id)*24*60*60));

我想从有效性计算到期日期,这在 internet_package 表中可用。但是这个插入查询抛出错误说:“字段列表”中的未知列“new.recharge_date”。我该如何解决?

4

1 回答 1

0
insert into recharge (user_id, package_id, recharge_date, expiry_date)
select 'datta_vcc','mb02','2013-05-06',date_add('2013-05-06', INTERVAL validity day)
from internet_package
where internet_package.package_id = 'mb02';

For now this seems to work. The hard-coded values will be fetched from a form in the front end. Can this query be optimized further?

于 2013-08-10T10:01:50.630 回答