Solved

help with query?

Posted on 2012-03-23
8
260 Views
Last Modified: 2012-03-26
I need a little help with sql query.

I have the tblAuthor(authorID,surname,givenname)
tblAssociation(associationID, publicationID,AuthorID)

I am trying to list coauthors here of given authorID.

Authors are tied to publication.

select authorID,surname,givenname from tblauthor a  inner join tblAssociation b on
a.authorid=b.authorid where b.publicationid in (
select publid from association where authorid=xxx)

Is that correct?
0
Comment
Question by:dkim18
  • 4
  • 3
8 Comments
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 50 total points
ID: 37758944
I don't think you need the inner query. Try:

SELECT auth.givenname, auth.surname
FROM tblAuthor auth
INNER JOIN tblAssociation asoc
ON auth.authorID = asoc.authorID
WHERE asoc.publicationID = xxx

Open in new window

0
 

Author Comment

by:dkim18
ID: 37758959
I am providing the authorid.
0
 

Author Comment

by:dkim18
ID: 37758961
With given authorid, I am trying to find any other authors who are tied to that publicationid.
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37759423
try this query

select a.authorID,a.surname,a.givenname, b.associationID
from tblauthor a  inner join tblAssociation b on
a.authorid=b.authorid where authorID=xxx
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 37759430
select a.authorID,a.surname,a.givenname, b.associationID,b.publicationid
from tblauthor a  inner join tblAssociation b on
a.authorid=b.authorid
where a.authorID=xxx
0
 

Author Comment

by:dkim18
ID: 37762579
Your sql finds all the publication for a search author.


I am trying to find all other authors who worked on that same publication with given an authorid.

ex) 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
 

Author Comment

by:dkim18
ID: 37762602
This brings back what I want.

How do I tie this up to the author main form?
If author main form's id is 3, how do I pass this to the subform whose data source is this query?





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])));
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 450 total points
ID: 37762821
you are posting different table names from your original post and up to your last post.

this is not a good way to present your problem..

anyway, see this link to help you get your main/sub form working


http://office.microsoft.com/en-us/access-help/create-a-form-that-contains-a-subform-a-one-to-many-form-HA010098674.aspx?CTT=3
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

803 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