sql server - SQL Inner Join query like LEFT OUTER JOIN -
i have problem sql inner join. tables, columns, data types , table values @ following image.
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
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
Post a Comment