新增一条数据的时候,添加if判断逻辑操作,具体sql如下:(MySQL数据库)
insert into t_coupon_record(account_id,coupon_id,coupon_name,valid_status) select 1002,1,'新人优惠5元代金券',1 from DUAL where not exists ( select account_id from t_coupon_record where account_id=1002 );
新增一条数据的时候,添加if判断逻辑操作,具体sql如下:(MySQL数据库)
insert into t_coupon_record(account_id,coupon_id,coupon_name,valid_status) select 1002,1,'新人优惠5元代金券',1 from DUAL where not exists ( select account_id from t_coupon_record where account_id=1002 );