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'。我该如何解决?
答案 0 :(得分: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';
目前这似乎有效。硬编码值将从前端的表单中获取。这个查询可以进一步优化吗?