Cannot execute full outer join?

179 views Asked by At

I am trying to execute this query. I'm not trying to use an ON keyword because i want to return all the rows from all 3 tables as one table.

SELECT Catalogue, Descriptionx, Quantity FROM pxxxA 
FULL OUTER JOIN
pxxxB 
FULL OUTER JOIN 
pxxxC

It is saying "Incorrect syntax near 'pxxxC'."

2

There are 2 answers

0
Michael Broughton On

When you say "i want to return all the rows from all 3 tables as one table.", if you have

Table 1 with rows 1 and 2 and TABLE 2 with rows A and B, do you want the full set of four possible combinations? "1 A, 1 B, 2 A, 2 B?"

Or two rows as if you had just lined the tables up next to each other? "1 A, 2 B"?

If the full set of combinations, then a CROSS JOIN is what you want. Otherwise you need to specify join criteria on an outer join to line up the rows.

0
jbg On

You still need to include how the ON statement, the full outer join will include anything that matched or not.

SELECT Catalogue, Descriptionx, Quantity
FROM pxxxA 
FULL OUTER JOIN
pxxxB 
ON pxxxA.column = pxxxB.column, etc.
FULL OUTER JOIN 
pxxxC
ON pxxxB.column - pxxxC.column, etc.