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.
| Author |
Topic |
|
dmaxj
Posting Yak Master
174 Posts |
Posted - 2010-06-25 : 23:14:22
|
| Is there anyway to join these three tables:Person----------pkPersonIDLastNameFirstNameResults-----------fkPersonIDReading1Reading2Reading3Reading4Comments-----------fkPersonIDEventDateCommentsI have been able to join the Person and Results tables. How can I join the Comments table so that I have one dataset? This is what I have so far:SELECT *FROM Person INNER JOIN Results ONPerson.pkPersonID = Results.fkPersonIDRegards |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-06-25 : 23:48:15
|
| Try this:SELECT *FROM Person INNER JOIN Results ONPerson.pkPersonID = Results.fkPersonIDINNER JOIN Comments ON Person.pkPersonID= Comments.fkPersonIDRegards,BohraI am here to learn from Masters and help new bees in learning. |
 |
|
|
dmaxj
Posting Yak Master
174 Posts |
Posted - 2010-06-26 : 00:35:45
|
| I tried above code, but I am not getting desired result... I want to join Person with Results and Person with Comments.Is this possible?Regards |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2010-06-26 : 00:43:29
|
please post some sample data with expected result KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
dmaxj
Posting Yak Master
174 Posts |
Posted - 2010-06-26 : 01:05:56
|
| I am trying to get a dataset that contains:pkPersonID, LastName, FirstName, Reading1, Reading2, Reading3, Reading4, EventDate, CommentsRegards |
 |
|
|
dmaxj
Posting Yak Master
174 Posts |
Posted - 2010-06-28 : 19:58:50
|
| So it looks like more than one table cannot be joined to the same table? Given tables A, B, C:Table A can be joined to B and then B to C....Table A can joined to B and A joined to C - is this possible?I considered using UNION, but the columns do not match in all tables. I also considered a subquery, but I am not sure if this could work. Any clues?Regards |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2010-06-29 : 11:39:11
|
| What you want for output doesn't seem clear to me. Bohra posted a query that seemed to be exactly what you asked for, but apparently is not what you wanted. We can help you better if you supply some sample data and expected output in a consumable format. Here is a link that might help you:http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx |
 |
|
|
|
|
|
|
|