Solved

Name conflict needs to use correlation names

Posted on 2007-04-02
5
2,879 Views
Last Modified: 2012-05-05
For the following SQL statement I receive an error that state Tables or functions 'Offices' and 'Offices' have the same exposed names. Use correlation names to distinguish them.

SELECT *
FROM Services
INNER JOIN Offices ON CentralOffices.centralOfficeId = Services.startId
INNER JOIN Offices ON CentralOffices.centralOfficeId = Services.endId

Any suggestions on how to go about doing so? TIA.
0
Comment
Question by:CodeParadise
5 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 125 total points
ID: 18839565
use table aliases:

SELECT *
FROM Services s
INNER JOIN Offices o1 ON o1.centralOfficeId = s.startId
INNER JOIN Offices o2 ON o2.centralOfficeId = s.endId
0
 
LVL 29

Assisted Solution

by:QPR
QPR earned 125 total points
ID: 18839567
SELECT *
FROM Services
INNER JOIN Offices O1 ON CentralOffices.centralOfficeId = Services.startId
INNER JOIN Offices 02 ON CentralOffices.centralOfficeId = Services.endId

would solve the ambiguity... but you don't seem to be joining on the table Offices
Your "on" needs to match a key from services to offices, not CentralOffices
0
 
LVL 4

Author Comment

by:CodeParadise
ID: 18839588
Sorry, my code should be

SELECT *
FROM Services
INNER JOIN CentralOffices ON CentralOffices.centralOfficeId = Services.startId
INNER JOIN CentralOffices ON CentralOffices.centralOfficeId = Services.endId

I'll give the suggestions a shot right now.
0
 
LVL 4

Author Comment

by:CodeParadise
ID: 18839619
Thanks for help guys. It's much appreciated.
0
 

Expert Comment

by:scollege
ID: 20867589
Doesn't work for me. Get the error:

The multi-part identifier "[table.column]" could not be bound.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

773 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