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
 Transact-SQL (2000)
 joining 3 or more table

Author  Topic 

aden
Starting Member

23 Posts

Posted - 2006-09-20 : 14:41:35
how can i join 3 tables with the same key like accountno?

what if only two of them have the same key?

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2006-09-20 : 14:50:04
Table definitions, please...

"I have HAD it with these muthu-f$#%in' cursors in my muthu-f$#%in' database!"
Go to Top of Page

aden
Starting Member

23 Posts

Posted - 2006-09-20 : 14:58:55
enough is enough

conthist

USERID String 8 User
ACCOUNTNO String 20 Account number
SRECTYPE String 1 First character of RecType (A record type code identifying different types of records within the database)
RECTYPE Sting 10 Record type
ONDATE Date 8 Action date
ONTIME String 5 Action time
ACTVCODE String 3 Activity code
STATUS String 2 First character is flag, second equals 1 if notes exist.

contact1

ACCOUNTNO String 20 Account number
COMPANY String 40 Company name
CONTACT String 40 Contact name
LASTNAME String 15 Contact's last name
DEPARTMENT String 35 Department
TITLE String 35 Contact title
SECR String 20 Secretary
PHONE1 String 25 Phone 1
PHONE2 String 25 Phone 2
PHONE3 String 25 Phone 3

contact2

ACCOUNTNO String 20 Account number
CALLBACKON Date 8 Call back date
CALLBACKAT String 8 Call back time (unused compatibility field)
CALLBKFREQ Smallint 3 Call back frequency
LASTCONTON Date 8 Last contact date
LASTCONTAT String 8 Last contact time
LASTATMPON Date 8 Last attempt date
LASTATMPAT String 8 Last attempt time
MEETDATEON Date 8 Meeting date
MEETTIMEAT String 8 Meeting time

i need to compan.comtact1, callbackon.contact2, status.conthist
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2006-09-21 : 12:53:39
Apparently enough is insufficient.
If you cannot be bothered to explain the problem clearly and completely, then why should anybody respond to help you? I, and others, are willing to spend some time helping you solve your problem, but we do not want to waste our time trying to guess what the problem is.
This:
how can i join 3 tables with the same key like accountno?

what if only two of them have the same key?

...and this:
i need to compan.comtact1, callbackon.contact2, status.conthist
...are not parsable statements in SQL, VB, English, or any other language.
And "string" is not a datatype.
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2006-09-21 : 15:27:53
blindman, that's hilarious!

But let's put aden out of their misery


SELECT contact1.company, contact2.callbackon, conthist.status
FROM conthist
INNER JOIN contact1 ON contact1.accountno = conthist.accountno
INNER JOIN contact2 ON contact2.accountno = conthist.accountno
Go to Top of Page

blindman
Master Smack Fu Yak Hacker

2365 Posts

Posted - 2006-09-21 : 16:44:46
If I was sure that was what he wanted, I'd have suggested it already. I'm just not into playing guessing games on the forums anymore. Too many bad experiences spending hours trying to figure out what a person wants, when they are unwilling or unable to take the time to explain their requirements clearly.
I hope for aden's sake that your code solves his problem.

"Once you establish possibility, all that remains are desire and determination."
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2006-09-21 : 16:57:58
That's why you're the Aged Yak Warrior and I'm just the rookie
Go to Top of Page
   

- Advertisement -