Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 I nedd another way to write this join .

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2006-10-12 : 07:49:03
fad writes "Hi,,

I needed to know that can this query be written in another way .
Windows 2000,Microsoft Sql Server 2000, Service Pack 2

Query:
=====


select p.ProductName ,a.AreaName,pd.Price from Product p
Cross join Area a left outer join ProductDetail pd on p.ProductID=pd.ProductID
and a.AreaID=pd.AreaID
order by a.AreaName

Actually its realted to a previous question i posted ,,, there r 3 tables namely Product,Ara,ProductDetails .It gives the following result:

1) The price of each product (area wise).
2) If a product is not available in the AREA then NULL should be printed in the price column."

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-10-12 : 07:57:58
something like this?

select p.ProductName ,a.AreaName,pd.Price 
from Product p
join ProductDetail pd on p.ProductID=pd.ProductID
left join Area a on a.AreaID=pd.AreaID
order by a.AreaName




Harsh Athalye
India.
"Nothing is Impossible"
Go to Top of Page
   

- Advertisement -