There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
access audio avg avg 8 bios blue screen boot bsod computer connection cpu crash css dell desktop dma driver drivers dvd email error excel explorer firefox firefox 3 freeze gimp graphics hard drive hardware hijackthis hjt install internet internet explorer itunes keyboard laptop macro malware monitor motherboard network networking outlook outlook 2003 outlook 2007 outlook express pio problem problems router seo server slow sound sp3 spyware trojan usb video virtumonde virus vista vundo windows windows vista windows xp winxp wireless
Software Development
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Software & Hardware > Software Development >
Solved: Trying to inner join 3 tables...for the first time


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

 
Thread Tools
therealSqueeker's Avatar
Junior Member with 19 posts.
 
Join Date: Apr 2008
Experience: Intermediate
17-Jul-2008, 09:52 AM #1
Question Solved: Trying to inner join 3 tables...for the first time
I am trying to join 3 tables Med_Prof , Med_Prof_Facilities, and Med_Prof_Offices in SQL on Med_Prof_Record_No and keep getting Ambiguous column name erro . Any help would be great as I am not to good at this. Thanking you in advance
Chicon's Avatar
Computer Specs
Distinguished Member with 6,608 posts.
 
Join Date: Jul 2004
Location: 50° 34' 07.13" N - 04° 10' 23.
Experience: Second socks retriever
17-Jul-2008, 10:42 AM #2
Hi therealSqueeker,

You should either give alias names to your tables to differentiate the columns names or use the complete name of your columns.

Examples using tables tableA, tableB with common column name id:

Code:
SELECT * FROM tableA a
    INNER JOINT tableB b
        ON a.id = b.id
Code:
SELECT * FROM tableA
    INNER JOINT tableB
        ON tableA.id = tableB.id
therealSqueeker's Avatar
Junior Member with 19 posts.
 
Join Date: Apr 2008
Experience: Intermediate
17-Jul-2008, 10:50 AM #3
Hi there!! Thank you so much...going to give it a try and let you know...tried something similar and it didn't work so keep your fingers crossed;-)
therealSqueeker's Avatar
Junior Member with 19 posts.
 
Join Date: Apr 2008
Experience: Intermediate
17-Jul-2008, 11:33 AM #4
Ok....here's the latest error...

The number name 'MSO.dbo.Med_Prof.a' contains more than the maximum number of prefixes. The maximum is 3.

What the code looks like

FROM [MSO].[dbo].[Med_Prof] a
INNER JOIN [MSO].[dbo].[Med_Prof_Offices] b

ON [MSO].[dbo].[Med_Prof].a.[Med_Prof_Record_No]=[MSO].[dbo].[Med_Prof_Offices].b.[Med_Prof_Record_No]
Chicon's Avatar
Computer Specs
Distinguished Member with 6,608 posts.
 
Join Date: Jul 2004
Location: 50° 34' 07.13" N - 04° 10' 23.
Experience: Second socks retriever
17-Jul-2008, 04:10 PM #5
Quote:
...
ON [MSO].[dbo].[Med_Prof].a.[Med_Prof_Record_No]=[MSO].[dbo].[Med_Prof_Offices].b.[Med_Prof_Record_No]
As a is an alias for [MSO].[dbo].[Med_Prof] and
b is an alias for [MSO].[dbo].[Med_Prof_Offices], the ON statement should be :
ON a.[Med_Prof_Record_No] = b.[Med_Prof_Record_No]
therealSqueeker's Avatar
Junior Member with 19 posts.
 
Join Date: Apr 2008
Experience: Intermediate
17-Jul-2008, 04:14 PM #6
Thank you!
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 06:35 PM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.