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)
 SQL error on join statement

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-11-01 : 07:44:51
tricia writes "Hi, I'm using this query to join data from 3 tables:

select customers.customerid, customers.country,
orders.orderid, orders.orderdate,
orderdetails.unitprice
from customers
join customers on orders.orderid = orderdetails.orderid
where country <> 'usa'
and orderdate > '11/1/4'

and I get this error message:
Tables or functions 'customers' and 'customers' have the same exposed names. Use correlation names to distinguish them.

I'm stuck on what to do next. Any help would be appreciated."

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-11-01 : 07:46:16
there's no orders table in your query

Go with the flow & have fun! Else fight the flow
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2005-11-01 : 07:59:40
Or any orderdetails table!

from customers
join customers on orders.orderid = orderdetails.orderid

Kristen
Go to Top of Page

PlaniB
Starting Member

4 Posts

Posted - 2005-11-01 : 08:17:52
select customers.customerid, customers.country, orders.orderid, orders.orderdate, [order details].unitprice
from customers
inner join orders on customers.customerid=orders.customerid
inner join [order details] on orders.orderid=[order details].orderid
where customers.country <> 'usa' and orders.orderdate > '1996-08-01 00:00:00.000'

This going to work. Test it and see if you want this kind of result.

Go to Top of Page
   

- Advertisement -