Skip to content
Advertisement

SQL table.column not working when I use it with full join

I have this SQL query:

And it returns the error :

“unknown column main.cname in filed list”.

while the column certainly exists:

seems alright.

I tried using aliases but it just made it worse. I’m clueless

Advertisement

Answer

As coyeb60297 has pointed out, MySQL doesn’t do full outer joins so your query is:

and because main has been aliased as full, you can’t say main.cname because main is not a thing

This would work:

.. but it isn’t a full join (it just better explains the point above).

Consider instead something like:

If you face performance issues with the full join consider:

  1. do you really need it?
  2. MatBailie’s suggestion to union on only those rows the left join lacks: (a LEFT JOIN b) UNION ALL (a RIGHT JOIN b WHERE a.id IS NULL)
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement