From: Cine on 15 Apr 2010 09:14 Hello, Im new to queries and i'm trying to pull off a seemingly tricky one. Somehow I need to 'merge' or 'combine' the two queries below into one: [CODE]SELECT TopicName, Duration FROM tblTopics WHERE (TopicCode IN (@TopicCode1, @TopicCode2)) [/CODE] [CODE]SELECT DateStarted, DateToEnd FROM tblSubscriptions WHERE (UserID = @UserID) AND (TopicCode IN (@TopicCode1, @TopicCode2)) [/CODE] At first glance I thought this was impossible to do but it's worth a try posting on a forum where people know alot more than me on the subject :) Any ideas?
From: vanderghast on 15 Apr 2010 10:03 [CODE] SELECT t.TopicName, t.Duration, s.DateStarted, s.DateToEnd FROM tblTopics AS t INNER JOIN tblSubscriptions AS s ON t.topicCode = s.topicCode WHERE t.topicCode IN( @topicCode1, @topicCode2) AND s.UserID = @userID [/CODE] should do, assuming that topicCode is unique in either tblTopics, either in tblSubscriptions. If it is not unique in BOTH tables, say it appears twice in each table, then you will get four records, in the result, one for each possible (here unrestricted) match. Vanderghast, Access MVP "Cine" <u59375(a)uwe> wrote in message news:a68f85b1c85fd(a)uwe... > Hello, > > Im new to queries and i'm trying to pull off a seemingly tricky one. > > Somehow I need to 'merge' or 'combine' the two queries below into one: > > [CODE]SELECT TopicName, Duration > FROM tblTopics > WHERE (TopicCode IN (@TopicCode1, @TopicCode2)) [/CODE] > > [CODE]SELECT DateStarted, DateToEnd > FROM tblSubscriptions > WHERE (UserID = @UserID) AND (TopicCode IN (@TopicCode1, > @TopicCode2)) > [/CODE] > > At first glance I thought this was impossible to do but it's worth a try > posting on a forum where people know alot more than me on the subject :) > > Any ideas? >
|
Pages: 1 Prev: How to convert Null values to zero when create an average query Next: Remaining Balance Query |