Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Same exposed names

Status
Not open for further replies.

rrajarat

MIS
Oct 8, 2002
42
US
SELECT audit_trail.vendor,
SUM(audit_trail.quantity),
sdmn.reject,
vendor.code
FROM vendor LEFT OUTER JOIN sdmn ON
vendor.code = sdmn.supplier AND
sdmn.day >= '10/01/02' AND
sdmn.day <= '10/30/02',
vendor LEFT OUTER JOIN audit_trail ON
vendor.code = audit_trail.vendor AND
audit_trail.type = 'R' AND
audit_trail.date_stamp >= '10/01/02' AND audit_trail.date_stamp <= '10/30/02'
WHERE vendor.code = 'WHI018'
GROUP BY audit_trail.vendor,
sdmn.reject,
vendor.code

when I execute the above query I get this error:

Tables or functions 'vendor' and 'vendor' have the same exposed names. Use correlation names to distinguish them.

What does this mean? I thought it meant that sql server didn't know whether to use the vendor in the first or second join. If I am right how can I fix this problem?

Thanks for your help
 
hi,

Try this query

SELECT audit_trail.vendor,
SUM(audit_trail.quantity),
sdmn.reject,
vendor.code
FROM vendor
LEFT OUTER JOIN sdmn ON vendor.code = sdmn.supplier AND sdmn.day >= '10/01/02' AND sdmn.day <= '10/30/02'
LEFT OUTER JOIN audit_trail ON vendor.code = audit_trail.vendor AND audit_trail.type = 'R'
AND audit_trail.date_stamp >= '10/01/02' AND audit_trail.date_stamp <= '10/30/02'
WHERE vendor.code = 'WHI018'
GROUP BY audit_trail.vendor, sdmn.reject, vendor.code

Sunil
 
Thanks sunila7 but this query gives 3 errors

Invalid object name 'vendor'.
Invalid object name 'sdmn'.
Invalid object name 'audit_trail'.


 
Hi,

vendor,sdmn,audit_trail r these tables in ur DB, if not replace it with correct DB names

Sunil
 
Hi,

vendor,sdmn,audit_trail r these tables in ur DB, if not replace it with correct table names

Sunil
 
Yes these tables are in the DB. I wish it was that simple :)
 
Are you running this in Query Analyzer? If not please do so. When you get the error message, double click on the error and see which line of code gets highlighted. Is it for sure the FROM section that is erroring?

-SQLBill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top