As others have argued, the (+) syntax is an obsolete, proprietary syntax that Oracle has used for many years to achieve the same results as OUTER JOIN . I assume that they adopted their own syntax before SQL-92 decided on a standard syntax.
The equivalent query to the one you showed using the standard SQL OUTER JOIN (which is now supported by all major RDBMS implementations) will be as follows:
SELECT Table1.Category1, Table1.Category2, COUNT(*) AS Total, COUNT(Table2.Stat) AS Stat FROM Table1 LEFT OUTER JOIN Table2 ON (Table1.PrimaryKey = Table2.ForeignKey) GROUP BY Table1.Category1, Table1.Category2;
It means:
- All rows from
Table1 are included in the query result. - If there are matching rows in
Table2 , specify these rows (repeating the contents of Table1 , if there are several matching rows in Table2 ). - If
Table2 does not have matching rows, use NULL for all Table2 columns in the query result.
Bill Karwin Jan 10 '09 at 0:52 2009-01-10 00:52
source share