Solved

search authors sql help?

Posted on 2012-03-25
4
300 Views
Last Modified: 2012-03-25
Hi,

I need help with the sql.

I have a tblAuthor(authorid, surname,givenname)
tblAssociation(associationid,publicationid,authorid)
tblPublication(publicationid,title)


I am trying to find all other authors(coauthors) who worked on the same publcation with given an authorid.

ex) coauthors of author1 are 2,3,4,5
      coauthors of author2 are 1,5,7
     coauthors of author3 are 1,4
     coauthors of author4 are 1,3  etc
     
      publication1, author1,author3,author4  
      publciation2, author1,author2,author5
      publication3, author2,author1,author7
      publication4,author6,author7


 tblassociation(1,1,1)
 tblassociation(2,1,3)
 tblassociation(3,1,4)
 tblassociation(4,2,1)
 tblassociation(5,2,2)
 tblassociation(6,2,5)
 tblassociation(7,3,2)
 tblassociation(8,3,1)
 tblassociation(9,3,7)
 tblassociation(10,4,6)
 tblassociation(11,4,7)
0
Comment
Question by:dkim18
  • 3
4 Comments
 
LVL 61

Expert Comment

by:mbizup
ID: 37762609
Select AuthorId
From tblassociation
where pubid in
(Select pubid from tblassociation
Where authorid= [enter author id]
0
 
LVL 61

Expert Comment

by:mbizup
ID: 37762619
I missed a closing parenthesis in that:



Select AuthorId
From tblassociation
where pubid in
(Select pubid from tblassociation
Where authorid= [enter author id])
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 37762624
An alternative which might have better performance:


SELECT AuthorId
FROM tblassociation
INNER JOIN
(SELECT pubid FROM tblassociation
WHERE authorid= [enter author id]) AS a
ON tblassociation.PubID = a.PubID
0
 

Author Comment

by:dkim18
ID: 37762632
I think that's what I got.

SELECT Affiliation.AuthorID, Author.Surname, Author.Given_Name
FROM Author INNER JOIN Affiliation ON Author.AuthorID = Affiliation.AuthorID
WHERE (((Affiliation.PublicationID) In (SELECT Affiliation.PublicationID FROM Affiliation WHERE Affiliation.AuthorID=[xxxx])));

Thanks for checking it out.
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

837 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question