Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 Mysql says "unknown column" when doing full join

views
     
TSseiferalmercy
post Sep 16 2020, 09:54 PM, updated 6y ago

Getting Started
**
Junior Member
135 posts

Joined: May 2010


So I executed this command:

select*
from customer
full.join orders
on customer.ID = orders.customerid;

it gave me this error "error 1054 unknown column 'customer.ID' in 'on clause'

The strange thing is, when I execute the same set of commands for an inner join, it works just fine.
narf03
post Sep 16 2020, 10:39 PM

Look at all my stars!!
*******
Senior Member
4,547 posts

Joined: Dec 2004
From: Metro Prima, Kuala Lumpur, Malaysia, Earth, Sol


What's that dot for between full join?


https://www.codeproject.com/Articles/33052/...on-of-SQL-Joins

This post has been edited by narf03: Sep 16 2020, 10:42 PM
TSseiferalmercy
post Sep 16 2020, 10:49 PM

Getting Started
**
Junior Member
135 posts

Joined: May 2010


QUOTE(narf03 @ Sep 16 2020, 10:39 PM)
Thanks, I removed the dot, same problem.


ketnave
post Sep 16 2020, 10:52 PM

Enthusiast
*****
Senior Member
868 posts

Joined: Sep 2009
From: douchistan, pekopon


Already suggested before, post to sqlfiddle ... it will be easier for others to help.


jackoats.my
post Sep 17 2020, 08:32 PM

Getting Started
**
Junior Member
122 posts

Joined: Oct 2019
QUOTE(seiferalmercy @ Sep 16 2020, 10:49 PM)
Thanks, I removed the dot, same problem.
*
Try this on Oracle SQL. Might be diff for other variants

CODE

select*
from customers
full outer join orders
on customers.customerID = orders.customerID;


This post has been edited by jackoats.my: Sep 17 2020, 08:34 PM
jackoats.my
post Sep 17 2020, 08:38 PM

Getting Started
**
Junior Member
122 posts

Joined: Oct 2019
Is there a column called ID in your customer table?

>>>unknown column 'customer.ID'



QUOTE(seiferalmercy @ Sep 16 2020, 09:54 PM)
So I executed this command:

select*
from customer
full.join  orders
on customer.ID = orders.customerid;

it gave me this error "error 1054 unknown column 'customer.ID' in 'on clause'

The strange thing is, when I execute the same set of commands for an inner join, it works just fine.
*
This post has been edited by jackoats.my: Sep 17 2020, 08:38 PM
jackoats.my
post Sep 17 2020, 08:50 PM

Getting Started
**
Junior Member
122 posts

Joined: Oct 2019
FULL OUTER JOIN is equivalent to

LEFT OUTER JOIN
UNION
RIGHT OUTER JOIN

So you can also try the above step if the FULL OUTER JOIN doesn't work.


QUOTE(seiferalmercy @ Sep 16 2020, 09:54 PM)
So I executed this command:

select*
from customer
full.join  orders
on customer.ID = orders.customerid;

it gave me this error "error 1054 unknown column 'customer.ID' in 'on clause'

The strange thing is, when I execute the same set of commands for an inner join, it works just fine.
*
TSseiferalmercy
post Sep 17 2020, 09:00 PM

Getting Started
**
Junior Member
135 posts

Joined: May 2010


QUOTE(jackoats.my @ Sep 17 2020, 08:38 PM)
Is there a column called ID in your customer table?

>>>unknown column 'customer.ID'
*
yes there is

very strange...
jackoats.my
post Sep 17 2020, 09:07 PM

Getting Started
**
Junior Member
122 posts

Joined: Oct 2019
There is nothing strange about it. If there's actually no intersections between the two tables, then there will be no outer join. The error message might be telling you that.

But then you're saying there is an inner join between the two tables...

So there could a typo when you change from inner join to full outer join, or syntax error if MySQL does not support the syntax FULL JOIN.

QUOTE(seiferalmercy @ Sep 17 2020, 09:00 PM)
yes there is

very strange...
*
This post has been edited by jackoats.my: Sep 17 2020, 09:14 PM
bumpo
post Sep 18 2020, 11:02 AM

On my way
****
Junior Member
632 posts

Joined: Mar 2013


ts, you sure you are using mysql?

last i checked mysql dont support FULL JOIN and needs to be written as below to achieve it . UNION vs. UNION ALL depends on the outcome you're looking for

SELECT * FROM A
LEFT JOIN B ON A.key = B.key

UNION

SELECT * FROM A
RIGHT JOIN B ON A.key = B.key
TSseiferalmercy
post Sep 18 2020, 11:10 AM

Getting Started
**
Junior Member
135 posts

Joined: May 2010


QUOTE(bumpo @ Sep 18 2020, 11:02 AM)
ts, you sure you are using mysql?

last i checked mysql dont support FULL JOIN and needs to be written as below to achieve it . UNION vs. UNION ALL depends on the outcome you're looking for

SELECT * FROM A
  LEFT JOIN B ON A.key = B.key

UNION

SELECT * FROM A
  RIGHT JOIN B ON A.key = B.key
*
yes I am. I’m new to this, so a lot of syntax I dont know.
bumpo
post Sep 18 2020, 11:18 AM

On my way
****
Junior Member
632 posts

Joined: Mar 2013


QUOTE(seiferalmercy @ Sep 18 2020, 11:10 AM)
yes I am. I’m new to this, so a lot of syntax I dont know.
*
interestingly enough when using FULL JOIN, mysql complains about unknown column but when infact it doesnt support it
your best bet is to rewrite it using UNION/UNION ALL
TSseiferalmercy
post Sep 18 2020, 11:26 AM

Getting Started
**
Junior Member
135 posts

Joined: May 2010


QUOTE(bumpo @ Sep 18 2020, 11:18 AM)
interestingly enough when using FULL JOIN, mysql complains about unknown column but when infact it doesnt support it
your best bet is to rewrite it using UNION/UNION ALL
*
Ahh I just realized something. There is no ID column for both tables. In one table the column is called 'customerID', in the other table is just 'ID'. Is that the reason for the error ?
TSseiferalmercy
post Sep 18 2020, 11:32 AM

Getting Started
**
Junior Member
135 posts

Joined: May 2010


QUOTE(jackoats.my @ Sep 17 2020, 08:50 PM)
FULL OUTER JOIN is equivalent to

LEFT OUTER JOIN
UNION
RIGHT OUTER JOIN

So you can also try the above step if the FULL OUTER JOIN doesn't work.
*
I used right outer join and it works

Thanks again. Could you suggest a website where I could get the whole list of syntax ?
bumpo
post Sep 18 2020, 11:33 AM

On my way
****
Junior Member
632 posts

Joined: Mar 2013


QUOTE(seiferalmercy @ Sep 18 2020, 11:26 AM)
Ahh I just realized something. There is no ID column for both tables. In one table the column is called 'customerID', in the other table is just 'ID'. Is that the reason for the error ?
*
error is complaining about 'on clause' meaning your joining condition.
most likely mysql is wrongly returning the error due to "full join"

jackoats.my
post Sep 20 2020, 12:09 AM

Getting Started
**
Junior Member
122 posts

Joined: Oct 2019
Ha, you can read the MySQL manual (documentation)


QUOTE(seiferalmercy @ Sep 18 2020, 11:32 AM)
I used right outer join and it works

Thanks again. Could you suggest a website where I could get the whole list of syntax ?
*
This post has been edited by jackoats.my: Sep 20 2020, 12:11 AM

 

Change to:
| Lo-Fi Version
0.0171sec    1.03    5 queries    GZIP Disabled
Time is now: 18th December 2025 - 09:46 AM