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)
 Check field and Union

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-02-11 : 08:48:52
Johnny writes "OS: Windows 2000 Adv. Server SP2
DB: SQL Server 2000 and/or MS Access

If I have two tables set up like this:

table1: issueID, issueName, isCurrentIssue

table2: issueID, articleName, articleAuthor, articleDate, articleTopic

Is there any way I can use a query to check table1.isCurrentIssue, and if it meets a criteria, union the two tables but only display the records from table2 where table2.issueID equals table1.issueID after the appropriate table1.issueID has been chosen?

I have in table1 the past issues of a magazine, with a field where I can specify whether or not the issue is the last/current issue. In table2 is a listing of articles in that are contained in each issue, with the issueID field tying the two tables together. I want to keep the two tables separate so that I don't have to have extra fields in each record.

Thanks in advance for any help.

Johnny Cook"

Lou
Yak Posting Veteran

59 Posts

Posted - 2002-02-12 : 12:49:26
table1: issueID, issueName, isCurrentIssue
table2: issueID, articleName, articleAuthor, articleDate, articleTopic

select table2.*
from table1 JOIN table2
on table1.issueID = table2.issueID
where table1.isCurrentIssue = 1



Go to Top of Page
   

- Advertisement -