Hi,
You can not do conditional joins to multiple tables in the SQL Server.But you can join both the tables using left join
and choose the values you need in the select statement using CASE statement.
Like.
select
O.orderID
Case When s.ItemId is not null then <Columns from Stock Table>
...
...
from
Orders o
Left join OrderItems oi on oi.OrderId=o.OrderId and oi.ItemId=O.ItemId
Left join Stock s on o.OrderId is null and s.ItemId=O.ItemId
Vinay Valeti| If you think my suggestion is useful, please rate it as helpful. If it has helped you to resolve the problem, please Mark it as Answer
No comments:
Post a Comment