Unix Technical Forum

SQL statement work in mysql4 but not mysql5

This is a discussion on SQL statement work in mysql4 but not mysql5 within the MySQL General forum forums, part of the MySQL category; --> I am going to upgrade my database from version 4 to 5. However I found some of my web ...


Go Back   Unix Technical Forum > Database Server Software > MySQL > MySQL General forum

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 10:30 PM
Jason Chan
 
Posts: n/a
Default SQL statement work in mysql4 but not mysql5

I am going to upgrade my database from version 4 to 5.
However I found some of my web application doesn't work on MySQL5

e.g following statement works in 4 but not 5

SELECT f.*, c.id as cat_id, c.position as cat_position, c.state as
cat_state, c.name as cat_name, c.description as cat_desc,
c.image, c.url, m.member_name as mod_name, m.member_id as
mod_id, m.is_group, m.group_id, m.group_name, m.mid
FROM ibf_forums f, ibf_categories c
LEFT JOIN ibf_moderators m ON (f.id=m.forum_id)
WHERE c.id=f.category
ORDER BY c.position, f.position

Error:
Unknown column 'f.id' in 'on clause'

The alias seem not working?
What should I do, I dont want to rewrite all my sql statement....

Thanks.

Jason




Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 10:30 PM
Peter Brawley
 
Posts: n/a
Default Re: SQL statement work in mysql4 but not mysql5

Jason

following statement works in 4 but not 5

SELECT f.*, c.id as cat_id, c.position as cat_position, c.state as
cat_state, c.name as cat_name, c.description as cat_desc,
c.image, c.url, m.member_name as mod_name, m.member_id as
mod_id, m.is_group, m.group_id, m.group_name, m.mid
FROM ibf_forums f, ibf_categories c
LEFT JOIN ibf_moderators m ON (f.id=m.forum_id)
WHERE c.id=f.category
ORDER BY c.position, f.position

Look up joins in the 5.0 or 5.1 manual. As of 5.0.12, MySQL implemented
ANSI/ISO compliance, breaking comma joins of the sort you use above. You
need explicit JOIN ... ON | USING syntax to remove referential ambiguities.

PB

-----

Jason Chan wrote:
> I am going to upgrade my database from version 4 to 5.
> However I found some of my web application doesn't work on MySQL5
>
> e.g following statement works in 4 but not 5
>
> SELECT f.*, c.id as cat_id, c.position as cat_position, c.state as
> cat_state, c.name as cat_name, c.description as cat_desc,
> c.image, c.url, m.member_name as mod_name, m.member_id as
> mod_id, m.is_group, m.group_id, m.group_name, m.mid
> FROM ibf_forums f, ibf_categories c
> LEFT JOIN ibf_moderators m ON (f.id=m.forum_id)
> WHERE c.id=f.category
> ORDER BY c.position, f.position
>
> Error:
> Unknown column 'f.id' in 'on clause'
>
> The alias seem not working?
> What should I do, I dont want to rewrite all my sql statement....
>
> Thanks.
>
> Jason
>
>
>
>
>
>



--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.408 / Virus Database: 268.13.1/470 - Release Date: 10/10/2006

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:29 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com