LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-15-2009, 03:01 PM   #1
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Rep: Reputation: 30
MySQL error, worked in v4?


Does this select look wrong?

Code:
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.
 
Old 05-15-2009, 06:06 PM   #2
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,126
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
didn't you tell it call u.id editid, so maybe you need to change the last part to ON editid = e.id WHERE editid = '72' ...
 
Old 05-21-2009, 12:57 PM   #3
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Original Poster
Rep: Reputation: 30
Quote:
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'
Doesn't seem to work.
 
Old 05-22-2009, 09:22 AM   #4
soleilarw
Member
 
Registered: Apr 2009
Posts: 107

Rep: Reputation: 19
This part looks wrong to me:
Quote:
mysql> SELECT u.id as editid, u.*, c.* , e.* from mos_users as u, ...
I would try
mysql> SELECT u.id as editid, u.*, c.* , e.* as u from mos_users, ...

Linux Archive

Last edited by soleilarw; 06-18-2009 at 04:04 AM.
 
Old 05-22-2009, 10:52 AM   #5
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Original Poster
Rep: Reputation: 30
That doesn't work either.
Quote:
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'
 
Old 05-22-2009, 10:16 PM   #6
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
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.
 
Old 05-23-2009, 10:54 AM   #7
norobro
Member
 
Registered: Feb 2006
Distribution: Debian Sid
Posts: 792

Rep: Reputation: 331Reputation: 331Reputation: 331Reputation: 331
Isnt this your problem?

From the MYSQL 5.0 reference manual:
Quote:
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.
 
Old 06-08-2009, 12:13 PM   #8
Zeno McDohl
Member
 
Registered: Apr 2005
Location: Saratoga, NY
Distribution: Slackware
Posts: 322

Original Poster
Rep: Reputation: 30
Hm that looks like the issue. Testing now.
Quote:
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ERROR 2002: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. SpellChainz Linux - Software 3 06-28-2007 11:46 AM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. SpellChainz Linux - Newbie 1 06-23-2007 03:35 PM
mysql databases on separate drives - worked 3.23, busted 4.1 whysyn Linux - Software 2 05-24-2006 03:25 PM
mysql error Can't connect to local MySQL server through socket '/var/lib/mysql/mysql. Dannux Linux - Software 3 03-24-2006 08:44 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration