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 

sql joins


Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -