The exact query:
SELECT
coupon_coupons
.code
,
coupon_coupons
.discountType
AS 'type',
coupon_coupons
.discountAmount
AS 'amount',
coupon_coupons
.discountApplied
AS 'applied',
coupon_coupons
.description
,
group_concat(coupon_targetsku
.sku
separator ';') AS 'targetsku'
FROMcoupon_coupons
LEFT JOINcoupon_targetsku
ONcoupon_coupons
.code
=coupon_targetsku
.code
WHEREcoupon_coupons
.code
= 'testCode'
coupon_coupons.code = primary key
coupon_targetsku.code = fk(coupon_coupons.code)
If the coupon_coupons
.code
is found in the database the query operates as expected, but when its not found the result set that is returned is one row with all NULL values. I'm guessing its something I'm doing wrong with the left join.
I would like this query to return zero rows if the code is not found.
I'm using mysql:
Server version 5.1.36-community-log
Protocol version: 10
This is my first time asking a question here please let me know if there is any other information i should be providing.
Thanks in advance.