?
Solved

help with query?

Posted on 2012-03-23
8
Medium Priority
?
270 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 200 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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 1800 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

777 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