Posted by stockblaster on 01/15/06 09:28
Hello
I am using stored procedure with sql 2005 (with Visual studio 2005)
I have two tables .. TABLE1 And TABLE2
>From TABLE1 i need to retrive the OrderID's of the 4 most top rows. so
i did:
SELECT TOP 4 OrderID FROM TABLE1 order by OrderID desc
Now what i am trying to do is take the 4 row results (4 OrderID's) i
got from
TABLE1 and check if the 4 rows (4 OrderID's) exist in TABLE2 for a
specific
userID i get by INPUT varible (@UserId)..
What i want to return is only which OrderID'S existed in TABLE2 for the
specific user.
If only 2 OrderID'S i retrived from TABLE1 exist in TABLE2 i will
return only 2 OrderID's (so i can do my output in visual studio 2005
using the reader())
I would appreciate this if anyone knows how to do this sql query , is
it possible to do this in 1 query? i want to put it in a stored
procedure.
Navigation:
[Reply to this message]
|