Posteado por: comentalo | julio 21, 2011

mysql message ERROR 1054 (42S22): Unknown column in ‘on clause’

Pregunta (problema)

Tenia en Mysql 4 un query pero hice migración a Mysql 5 y unos querys dejaron de funcionar y marcaron el siguiente error: mysql message ERROR 1054 (42S22): Unknown column in ‘on clause’

El caso era el siguiente:

Imagina 3 tablas t1,t2,t3 con los campos t1.a, t2.b y t3.c

El query funcionaba en Mysql 4 pero en Mysql 5 marcaba error:

mysql> select * from t1, t2 left outer join t3 on t1.a=t3.c;
ERROR 1054 (42S22): Unknown column ‘t1.a’ in ‘on clause’

SOLUCION:


create table t1 (a int);
create table t2 (b int);
create table t3 (c int);

select * from t1, t2 join t3 on t1.a=t3.c;
ERROR 1054 (42S22): Unknown column 't1.a' in 'on clause'

select * from t1, t2 left outer join t3 on t1.a=t3.c;
ERROR 1054 (42S22): Unknown column 't1.a' in 'on clause'

Solo puse entre paréntesis la tablas entre el from y el join

select * from (t1, t2) join t3 on t1.a=t3.c; 
select * from (t1, t2) left outer join t3 on t1.a=t3.c; 

Y funciona a la perfección... 

Advertisement

Deja un comentario

Fill in your details below or click an icon to log in:

Logo de WordPress.com

You are commenting using your WordPress.com account. Log Out / Cambiar )

Twitter picture

You are commenting using your Twitter account. Log Out / Cambiar )

Facebook photo

You are commenting using your Facebook account. Log Out / Cambiar )

Connecting to %s

Categorías

Seguir

Get every new post delivered to your Inbox.