Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Name conflict needs to use correlation names

Posted on 2007-04-02
5
Medium Priority
?
2,884 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
[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
5 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 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 500 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

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…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

661 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