table **salesrule_coupon**: fileds as the following:
coupon_id code
1 Registered_send_5
2 test
表:salesrule_coupon_usage
归档如下:
coupon_id customer_id times_used
1 1 1
1
... 14 ... 1..
现在,我想选择times_used
where code =Registered_send_5
customer_id=$id 的位置。sql命令怎么写?感谢你。
以下是我的,但它不起作用。
$sql = "SELECT times_used FORM salesrule_coupon_usage as a
left join salesrule_coupon as b on a.coupon_id = b.coupon_id
where b.code = 'Registered_send_5' and customer_id=".'$id.";
当我把
SELECT times_used FORM salesrule_coupon_usage as a
left join salesrule_coupon as b on a.coupon_id = b.coupon_id
where b.code = 'Registered_send_5' and customer_id=1
在 phpmyadmin 中。表明
您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以在第 1 行的“salesrule_coupon_usage as a left join salesrule_coupon as b on a.co”附近使用正确的语法