table **salesrule_coupon**: fileds as the following:
coupon_id code
1 Registered_send_5
2 test
table:salesrule_coupon_usage
fileds as the following:
coupon_id customer_id times_used
1 1 1
1
... 14 ... 1..
now, i want to select out times_used
where the code =Registered_send_5
where customer_id=$id. how to write the sql command? thank u.
the following is my but it not work.
$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.";
when i put
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
in phpmyadmin. it shows
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'salesrule_coupon_usage as a left join salesrule_coupon as b on a.co' at line 1
Why do you have the '
in from of the $id
?
It should be FROM
and not FORM
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With