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)
 Convert into single query

Author  Topic 

lane0618
Posting Yak Master

134 Posts

Posted - 2003-05-29 : 20:09:30
How do I do this in a single query?

select *
into #temp
from Packaging2MTX
where mtxid = 13

SELECT PackagingList.packID, PackagingList.desc1, #temp.mtxID
FROM PackagingList LEFT OUTER JOIN
#temp ON PackagingList.packID = #temp.packID

drop Table #temp

---------------------------
I want to end up with this, which I dont if I just do a left join. In other words, I want the nulls to appear:

packid desc1 mtxID
1 BP, KSP & MSP 13
2 BP, USP Levers NULL
3 BP, USP KI Knobs NULL
4 CP, USP Domestic NULL
5 CP, USP International 13



SamC
White Water Yakist

3467 Posts

Posted - 2003-05-29 : 20:47:18
SELECT PackagingList.packID, PackagingList.desc1, X.mtxID

FROM PackagingList

LEFT OUTER JOIN (

select *
from Packaging2MTX
where mtxid = 13


) X -- Gotta name the nested query

ON PackagingList.packID = X.packID


Is this it?

Sam

Go to Top of Page

lane0618
Posting Yak Master

134 Posts

Posted - 2003-05-29 : 21:50:05
That does the trick! Thanks!

Go to Top of Page
   

- Advertisement -