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 2005 Forums
 Transact-SQL (2005)
 NewBie Query help

Author  Topic 

john@seitmc.com
Starting Member

3 Posts

Posted - 2009-01-14 : 14:00:57
Can someone direct me to some help on where to find out how to pass the results of one query to another?

Scenario is...
I have a Product table, and a PriceListProductJoin Table. I need to be able to feed the Product Table a businesscodeid, and description and have the results (productID) sent to another query doing a select.

These two do most of it:
SELECT [ProductID]
,[BusinessCodeID]
,[InternetAvailable]
,[Discontinued]
,[DropShip]
,[ItemNumber]
,[Description]
,[DefaultPrice]
FROM [Inventory].[dbo].[Product] where [BusinessCodeID] = '16' and Description like 'Paw%' (returns 6 rows)

select * from [Inventory].[dbo].[PriceListProductJoin] where [PriceListID] = '2' and productid >= '2296' and productid <= '2300' (returns 6 rows)


I know this is probably old hat for you all but it is making my head hurt.

Thanks in Advance

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2009-01-14 : 14:47:21
Is there a reason why the result has to be "sent to" and other query, rather that just write one query that gives you what you want? You should also look up Table-Valued functions. We don't really have enuf info to fully answer your question.

Jim
Go to Top of Page

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2009-01-14 : 14:58:09
[code]
SELECT *
FROM [INVENTORY].[DBO].[PRICELISTPRODUCTJOIN]
WHERE [PRICELISTID] = '2'
AND PRODUCTID IN

(SELECT [PRODUCTID]
FROM [INVENTORY].[DBO].[PRODUCT]
WHERE [BUSINESSCODEID] = '16'
AND DESCRIPTION LIKE 'Paw%')
[/code]
Go to Top of Page

john@seitmc.com
Starting Member

3 Posts

Posted - 2009-01-14 : 15:00:55
No just need the results but the next will want to update based on results of second.
Go to Top of Page

john@seitmc.com
Starting Member

3 Posts

Posted - 2009-01-14 : 15:04:50
rohitkumar,
Thanks that worked. Just need to figure out how to do and update now... :) Thanks
Go to Top of Page

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2009-01-14 : 15:07:00
what do you want to update?
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-01-14 : 15:34:30
Or
quote:
Originally posted by rohitkumar


SELECT columns
FROM [INVENTORY].[DBO].[PRICELISTPRODUCTJOIN]PP
Inner join [INVENTORY].[DBO].[PRODUCT] PD
ON PP.ProductID = PD.ProductID
WHERE [PP.PRICELISTID] = '2'
AND [PD.BUSINESSCODEID] = '16'
AND [PD.DESCRIPTION] LIKE 'Paw%'



Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-01-16 : 00:20:50
which table to be update & wt r the columns to be updated can u mention the details
Go to Top of Page
   

- Advertisement -