ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
mysql> SELECT u.id as editid, u.*, c.* , e.* from mos_users as u, mos_user_extended_config as c LEFT JOIN mos_user_extended AS e ON u.id = e.id WHERE u.id = '72' AND c.id = '1';
ERROR 1054 (42S22): Unknown column 'u.id' in 'on clause'
I'm a bit confused why it errors out if this works:
Code:
mysql> SELECT u.id as editid FROM mos_users as u LIMIT 1;
+--------+
| editid |
+--------+
| 62 |
+--------+
1 row in set (0.01 sec)
I don't know for sure, but I think it worked when we were using MySQL 4.x, now we're using 5.x.
mysql> SELECT u.id as editid, u.*, c.* , e.* from mos_users as u, mos_user_extended_config as c LEFT JOIN mos_user_extended AS e ON editid = e.id WHERE editid = '72' AND c.id = '1';
ERROR 1054 (42S22): Unknown column 'editid' in 'where clause'
mysql> SELECT u.id as editid, u.*, c.* , e.* as u from mos_users, mos_user_extended_config as c LEFT JOIN mos_user_extended AS e ON u.id = e.id WHERE u.id = '72' AND c.id = '1';
ERROR 1051 (42S02): Unknown table 'u'
I would suggest that you get it working without the abbreviations and then add them since it looks as if your problem is with the abbreviations but maybe it is with something else.
CREATE TABLE t1 (i1 INT, j1 INT);
CREATE TABLE t2 (i2 INT, j2 INT);
CREATE TABLE t3 (i3 INT, j3 INT);
INSERT INTO t1 VALUES(1,1);
INSERT INTO t2 VALUES(1,1);
INSERT INTO t3 VALUES(1,1);
SELECT * FROM t1, t2 JOIN t3 ON (t1.i1 = t3.i3);
Previously, the SELECT was legal due to the implicit grouping of t1,t2 as (t1,t2). Now the JOIN takes precedence, so the operands for the ON clause are t2 and t3. Because t1.i1 is not a column in either of the operands, the result is an Unknown column 't1.i1' in 'on clause' error. To allow the join to be processed, group the first two tables explicitly with parentheses so that the operands for the ON clause are (t1,t2) and t3:
SELECT * FROM (t1, t2) JOIN t3 ON (t1.i1 = t3.i3);
Looks like you are right about it working previously.
SELECT u.id as editid, u.*, c.* , e.* from (mos_users as u, mos_user_extended_config as c) LEFT JOIN mos_user_extended AS e ON (u.id = e.id) WHERE u.id = '72' AND c.id = '1';
Works
Last edited by Zeno McDohl; 06-08-2009 at 12:17 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.