sql server - SQL Inner Join query like LEFT OUTER JOIN -


i have problem sql inner join. tables, columns, data types , table values @ following image.

enter image description here

my working query is:

select o.order_id, o.order_date, o.quantity,      p.part_id, p.part_code, p.part_name,     c.cust_id, c.cust_code, c.cust_name (([dbo].[order] o left outer join [dbo].[customer] c     on c.cust_id = o.cust_id) left outer join [dbo].[part] p     on p.part_id = o.part_id 

and returning enter image description here

so question is, want write query second image should use inner join make left outer join's job. wrote following query this

select distinct * [dbo].[order] o  inner join customer c     on (c.cust_id = o.cust_id or         o.cust_id null) 

but doesn't return left outer join query result me. how can without use left outer join ?

it depends on teacher's intent. if language question, , not logical operator question, use outer apply:

select o.*, d.* [dbo].[order] o  outer apply (     select *     [dbo].customer c     c.cust_id = o.cust_id ) d 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

javascript - angular ng-required radio button not toggling required off in firefox 33, OK in chrome -

xcode - Swift Playground - Files are not readable -