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
 General SQL Server Forums
 New to SQL Server Programming
 Stored procedures Help Please

Author  Topic 

nobby
Yak Posting Veteran

58 Posts

Posted - 2006-10-20 : 03:01:08
I'm Probably doing this all wrong so any guidance will be appreciated.

The Top select is filtered by the @MemberId parameter
I then want to filter the bottom select using the result of the first one
TourTypeId <> Tbl_01035_Tour_Players.TourTypeId


@MemberId int

AS
BEGIN
SET NOCOUNT ON;
SELECT MemberId, TourTypeId, TourStartDate, Paid
FROM Tbl_01035_Tour_Players
WHERE (MemberId = @MemberId)



SELECT TourTypeId, TourGame, TourDescr, TourDaysDur, TourMinPot, TourRecurring, TourRecurringBillDur, TourRecurringBillAmount_EnterNow,
ToursPerBilling_EnterNow, TourRecurringBillAmount, ToursPerBilling, TourFinished, TourAdminViewOnly, Settings_01, Settings_02, Settings_03,
Settings_04, Settings_05, Settings_06, Settings_07, Settings_08, Settings_09, Settings_10
FROM Tbl_01020_Tour_Types
WHERE (TourAdminViewOnly = 0) AND (TourFinished = 0) AND (TourRecurring = 1) AND (TourStartDate <= GETDATE()) and (TourTypeId <> Tbl_01035_Tour_Players.TourTypeId)
END

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2006-10-20 : 04:25:01
[code]SELECT
TourTypeId, TourGame, TourDescr, TourDaysDur, TourMinPot,
TourRecurring, TourRecurringBillDur, TourRecurringBillAmount_EnterNow,
ToursPerBilling_EnterNow, TourRecurringBillAmount, ToursPerBilling, TourFinished,
TourAdminViewOnly, Settings_01, Settings_02, Settings_03,
Settings_04, Settings_05, Settings_06, Settings_07, Settings_08, Settings_09, Settings_10
FROM Tbl_01020_Tour_Types
WHERE
TourAdminViewOnly = 0 AND
TourFinished = 0 AND
TourRecurring = 1 AND
TourStartDate <= GETDATE() and
TourTypeId not in (select top 1 TourTypeId from Tbl_01035_Tour_Players where MemberId = @MemberId)[/code]

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

nobby
Yak Posting Veteran

58 Posts

Posted - 2006-10-20 : 07:15:31
Harsh

Thanks for that all worked fine except had to remove the top 1 bit

Thanxs
Go to Top of Page
   

- Advertisement -