A: 

I replaced the tables and columns with my own and ran the query, and had the same errors. Removing different parts of the query gave me more errors relating to columns or tables not existing. I don't have an explanation for that, possibly because I have never used a FULL JOIN.

I found that changing FULL JOIN to another type of join fixed the issue. Try changing FULL JOIN to JOIN or RIGHT JOIN and see if those results do what you want.

Edit: Oh, I see your comment about needing FULL JOIN now. Could you rewrite the query with UNION instead?

Alex JL
I need full join, because some tables can have matches some don't
hey
+2  A: 

There's no FULL OUTER JOIN in MySQL - see this link for how to get the functionality.

$query = mysql_query("     SELECT * FROM COMPANY c
                       LEFT JOIN FACTORY f ON f.n_id = c.n_id
                      UNION ALL
                          SELECT * FROM COMPANY c
                      RIGHT JOIN FACTORY f ON f.n_id = c.n_id
                           WHERE c.? IS NULL
                             AND c.n_id = mysql_real_escape_string($n_id)
                             AND f.n_id = mysql_real_escape_string($n_id)") or die(mysql_error());

You need to update the ? to be the name of a column from the COMPANY table, other than n_id.

OMG Ponies
That's the one ugly query, I can't see her :/
hey
@hey: Check the link for alternative queries to produce the same result, but it doesn't change the fact that MySQL doesn't support the FULL keyword.
OMG Ponies