Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Mailing Lists -> Oracle-L -> Re: Join , Where
Oracle 9i added SQL 1999 support, which includes OUTER JOIN.
In SQL 92 syntax the where clause can have both the join
relationships and filter conditions. In SQL 1999 syntax
the where clause only contains filter conditions.
Note: Oracle 9i allows both SQL92 and SQL 1999 syntax to
peacefully coexist in the same statement (crazy to read).
Using the Oracle 9i HR example schema this query works:
SELECT country_name
, postal_code , department_name , employee_id , job_title
ON countries.country_id = locations.country_id LEFT OUTER JOIN departments
ON locations.location_id = departments.location_id LEFT OUTER JOIN employees
ON employees.department_id = departments.department_id AND employees.manager_id = departments.manager_id LEFT OUTER JOIN jobs
ON jobs.job_id = employees.job_id
Along the way I noticed that changing LEFT to RIGHT on
a line or two caused an intersection to occur in the
result set (effectively becoming an INNER JOIN).
Just wondering if this from clause works:
FROM polinesrc LEFT OUTER JOIN poline
ON polinesrc.company = poline.company AND polinesrc.po_code = poline.po_code AND polinesrc.po_number = poline.po_number AND polinesrc.po_release = poline.po_release AND polinesrc.line_nbr = poline.line_nbrLEFT OUTER JOIN popivuf
ON poline.item = popivuf.item AND poline.procure_group = popivuf.procure_group AND poline.vendor = popivuf.vendor
ON poline.company = itemloc.company AND poline.location = itemloc.location AND poline.item = itemloc.item
ON itemloc.item = itemmast.item
Have Fun :)
Teresita Castro wrote:
I run the query and it run even though in Rapid SQL send the next error: unexpected token:LEFT
My questions is what is the difference between where an join in Oracle, what is better and why?
>>> [EMAIL PROTECTED] 07/02/03 06:55PM >>>
Hi !!
(I am using Oracle 9.2)
I am trying to run the next query but I received an error in the from statement.
SELECT POLINE.ITEM AS CVEART,
POLINESRC.QUANTITY AS CANT_PE, ROUND( ITEMLOC.SOH_QTY - ( ITEMLOC.ALLOC_QTY +ITEMLOC.IN_PROC_QTY), 2) AS EXIS_BOD,
WHEN POLINE.ENT_BUY_UOM='UNID' THEN 'P' WHEN SUBSTR(POLINE.ENT_BUY_UOM,1,1)='C' THEN 'C' END UNIDAD,
END EL_CANT_EM, POLINE.ENT_BUY_UOM AS EL_UNID_EM, POLINE.DESCRIPTION AS EL_DESCRIP, POLINE.PURCH_MAJCL AS EL_NO_FAM, CASE POLINE.TAX_CODE WHEN 'IVA 0%' THEN POLINE.TAXBL_UNT_CST WHEN 'IVA 10%' THEN POLINE.TAXBL_UNT_CST*1.1 WHEN 'IVA 15%' THEN POLINE.TAXBL_UNT_CST*1.15 ELSE ENT_UNIT_CST END EL_COSTO,
WHEN '2000' THEN POPIVUF.PIV_USR_FLD_01 WHEN '2001' THEN POPIVUF.PIV_USR_FLD_02 WHEN '2002' THEN POPIVUF.PIV_USR_FLD_03 ELSE '0' END EL_PAC_PRO FROM POLINESRC LEFT OUTER JOIN POPIVUF RIGHT OUTER JOIN POLINE ON POPIVUF.ITEM = POLINE.ITEM AND POPIVUF.PROCURE_GROUP = POLINE.PROCURE_GROUP AND POPIVUF.VENDOR = POLINE.VENDOR ON POLINESRC.COMPANY = POLINE.COMPANY AND POLINESRC.PO_CODE = POLINE.PO_CODE AND POLINESRC.PO_NUMBER = POLINE.PO_NUMBER AND POLINESRC.PO_RELEASE = POLINE.PO_RELEASE AND POLINESRC.LINE_NBR = POLINE.LINE_NBR LEFT OUTER JOIN ITEMLOC LEFT OUTER JOIN ITEMMAST ON ITEMLOC.ITEM = ITEMMAST.ITEM ON POLINE.COMPANY = ITEMLOC.COMPANY AND POLINE.LOCATION = ITEMLOC.LOCATION AND POLINE.ITEM =ITEMLOC.ITEM
POPOIVUF-POLINE ( all rows from POLINE)
PROCURE_GROUP
ITEM
VENDOR
POLINESRC-POLINE (all rows from POLINESRC)
COMPANY
PO_CODE PO_NUMBER PO_RELEASE
WHERE ( (poline.company = pol.company)
AND (poline.po_code = pol.po_code) AND (poline.po_number = pol.po_number) AND (poline.po_release = pol.po_release) AND (poline.line_nbr = pol.line_nbr) AND (popivuf.procure_group = poline.procure_group) AND (popivuf.item = poline.item) AND (popivuf.vendor = poline.vendor) AND (itemloc.item = itemmast.item_group) AND (itemloc.company = poline.company) AND (poline.LOCATION = itemloc.LOCATION) AND (itemloc.item = poline.item) )
I was running the query in SQL Server 2000, and it works fine there, what I am doing wrong ???
-- Please see the official ORACLE-L FAQ: http://www.orafaq.net -- Author: Chip INET: [EMAIL PROTECTED] Fat City Network Services -- 858-538-5051 http://www.fatcity.com San Diego, California -- Mailing list and web hosting services --------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: [EMAIL PROTECTED] (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Sat Jul 05 2003 - 02:11:16 CDT
![]() |
![]() |