Solved

How to correct ORA-00918- Column ambiguously defined

Posted on 2007-11-29
2
2,400 Views
Last Modified: 2013-12-07
Need to correct this query
select matrectrans.itemnum,matrectrans.LINETYPE, matrectrans.GLDEBITACCT,
matrectrans.assetnum,matrectrans.location,
matrectrans.tostoreloc, matrectrans.ISSUETYPE,matrectrans.refwo,
matrectrans.ponum, matrectrans.quantity,
matrectrans.linecost, matrectrans.description,matrectrans.status,
matrectrans.siteid,matrectrans.actualdate, po.vendor, companies.name
from matrectrans left outer join po
on matrectrans.ponum = po.ponum
and matrectrans.siteid = po.siteid,
companies left outer join po
on po.orgid = companies.orgid
0
Comment
Question by:ewgf2002
[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
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 20373262
I think you query should rather go like this:
select matrectrans.itemnum,matrectrans.LINETYPE, matrectrans.GLDEBITACCT, 
matrectrans.assetnum,matrectrans.location,
matrectrans.tostoreloc, matrectrans.ISSUETYPE,matrectrans.refwo,
matrectrans.ponum, matrectrans.quantity,
matrectrans.linecost, matrectrans.description,matrectrans.status,
matrectrans.siteid,matrectrans.actualdate, po.vendor, companies.name
from matrectrans 
left outer join po 
on matrectrans.ponum = po.ponum
and matrectrans.siteid = po.siteid
left outer join companies 
   on po.orgid = companies.orgid

Open in new window

0
 
LVL 14

Assisted Solution

by:GGuzdziol
GGuzdziol earned 250 total points
ID: 20373280
You use po table twice in outer join; I guess you wanted

from matrectrans left outer join po
on matrectrans.ponum = po.ponum and matrectrans.siteid = po.siteid
right outer join companies on po.orgid = companies.orgid

(or maybe left outer join? I do not know your logic, but I'm pretty sure you need po table once; this will give you proper data and get rid of ORA-00918. If you need po table twice in from clause then you have to alias it, i.e.
from ... left outer join po po1 on ... left outer join po po2 on ...)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Why doesn't the Oracle optimizer use my index? Querying too much data Most Oracle developers know that an index is useful when you can use it to restrict your result set to a small number of the total rows in a table. So, the obvious side…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
Via a live example, show how to take different types of Oracle backups using RMAN.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

705 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