mysql - How do I select all the dealers that did not have an order? -
i trying join 2 tables , select dealers did not have promo code used on order.
how can this?
i'm trying below, it's not working right. in example want bob, since promo_code
hasn't been used in orders.
select d.`name` z_dealer d left outer join z_order o on (d.promo_code = o.promo_code) , o.promo_code null
here tables...
mysql> select * z_dealer; +----+------+------------+ | id | name | promo_code | +----+------+------------+ | 1 | john | holiday | | 2 | suzy | special | | 3 | bob | laborday | +----+------+------------+ mysql> select * z_order; +----+-------+------------+ | id | total | promo_code | +----+-------+------------+ | 1 | 10 | holiday | | 2 | 20 | special | | 3 | 15 | holiday | | 4 | 45 | special | +----+-------+------------+
select d.`name` z_dealer d left join z_order o on (d.promo_code = o.promo_code) o.promo_code null
Comments
Post a Comment