mysql - Join is not working in MY SQL -


select distinct c.fname, s.description customer c  inner join orders o on c.customer_num = o.customer_num inner join items on o.order_num = i.order_num inner join stock s on s.stock_num = i.stock_num i.manu_code = 'anz'; 

i'm confident join "working" in mysql.

(i add here example demonstrates works.)


edit

if have 2 or columns "in common" between 2 tables, , want reference both columns in equality comparisons in join predicate, add and col2 = col2 existing on clause...

for example, add condition cust_id equal between customer , orders

  select distinct c.fname        , s.description     customer c     join orders o        on o.customer_num = c.customer_num      , o.cust_id      = c.cust_id   -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^        add line     join items        on i.order_num = o.order_num     join stock s       on s.stock_num = i.stock_num    i.manu_code = 'anz'; 

if want join between customer , orders on either customer_num or cust_id, can replace and or. (but odd pattern, having 2 different columns match on; not normative pattern.)


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 -