Computer Webmaster Gaming Console Graphics Forum

Welcome to the Computer Webmaster Gaming Console Graphics Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

MK PitStop Main Earn $25 Earn Money Posting Extras Members Blogs Image Hosting User Pages
Go Back   Computer Webmaster Gaming Console Graphics Forum > Webmaster Forum > Website Coding > Database
Register FAQ/Rules Become A V.I.P. Member Search Today's Posts Mark Forums Read

Database Database problems or need to ask a question? maybe something to do with sql injections or a database software question. Database topics cover MySQL, PostgreSQL, Oracle, SQL Server or anything else related to databases.

Google
Closed Thread
 
LinkBack Thread Tools Display Modes
Old 05-31-2007, 8:47 PM   #1
Henri Schomäcker
 
Henri Schomäcker's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Still problems with left joins and mysql 5.1.x

Hi folks,

I still have problems with some queries (I hope, this is the last one!) in
my highly customised osCommerce shop with mysql-5.1.x
The same query works well in mysql 4.0.x and results in total=1!

With mysql 5.1.x I get the following errormessage:
ERROR: 1054 - Unknown column 'p.products_id' in 'on clause'

This is the query:
8<--------8<--------8<--------8<--------8<--------8<--------
select count(p.products_id) as total
from
products_description pd,
shops sh,
products p left join manufacturers m on
p.manufacturers_id = m.manufacturers_id,
products_to_categories p2c left join specials s on
p.products_id = s.products_id,
product_types pt
where
pt.product_type_id = p.product_type_id and
p.products_status = '1' and
sh.shop_id = p.shop_id and
p.products_id = p2c.products_id and
pd.products_id = p2c.products_id and
pd.language_id = '2' and
p2c.categories_id = '1769'
8<--------8<--------8<--------8<--------8<--------8<--------

As far as I could find out already, It could have something to do with the
new Server SQL Mode STRICT_TRANS_TABLES, but didn't really understand why
this would be relevant for a select or count query.

Now my question is:
How can this query be re-written to work in mysql-5.1.x ?
(Maybe not using joins? Is this possible? My tries still fail ;-))

Many thanks in advance,
It would be a very big help If someone could send me a probabely working
version for 5.1.x of this query.

Yours Henri

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Advertisements
Old 05-31-2007, 8:48 PM   #2
Ian Pawson
 
Ian Pawson's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Still problems with left joins and mysql 5.1.x

I have had a similar problem with joins in 5 that work ok in 4. From the
5 help file this would seem to be due the a change in the optimization
used to make it standards compliment. In your case it is dropping your
column. In my case moving the position of the join in the query got it
working in 5 but not in 4.

Henri Schomäcker wrote:
> Hi folks,
>
> I still have problems with some queries (I hope, this is the last one!) in
> my highly customised osCommerce shop with mysql-5.1.x
> The same query works well in mysql 4.0.x and results in total=1!
>
> With mysql 5.1.x I get the following errormessage:
> ERROR: 1054 - Unknown column 'p.products_id' in 'on clause'
>
> This is the query:
> 8<--------8<--------8<--------8<--------8<--------8<--------
> select count(p.products_id) as total
> from
> products_description pd,
> shops sh,
> products p left join manufacturers m on
> p.manufacturers_id = m.manufacturers_id,
> products_to_categories p2c left join specials s on
> p.products_id = s.products_id,
> product_types pt
> where
> pt.product_type_id = p.product_type_id and
> p.products_status = '1' and
> sh.shop_id = p.shop_id and
> p.products_id = p2c.products_id and
> pd.products_id = p2c.products_id and
> pd.language_id = '2' and
> p2c.categories_id = '1769'
> 8<--------8<--------8<--------8<--------8<--------8<--------
>
> As far as I could find out already, It could have something to do with the
> new Server SQL Mode STRICT_TRANS_TABLES, but didn't really understand why
> this would be relevant for a select or count query.
>
> Now my question is:
> How can this query be re-written to work in mysql-5.1.x ?
> (Maybe not using joins? Is this possible? My tries still fail ;-))
>
> Many thanks in advance,
> It would be a very big help If someone could send me a probabely working
> version for 5.1.x of this query.
>
> Yours Henri
>

 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Old 05-31-2007, 8:48 PM   #3
Henri Schomäcker
 
Henri Schomäcker's Avatar
 
Posts: n/a
My Photos: (0)

Banked:
MK Cash: $

I am Worth:
MK Cash: $
Donate

Recent Blog: None

Default Still problems with left joins and mysql 5.1.x

Ian Pawson wrote:

> I have had a similar problem with joins in 5 that work ok in 4. From the
> 5 help file this would seem to be due the a change in the optimization
> used to make it standards compliment. In your case it is dropping your
> column. In my case moving the position of the join in the query got it
> working in 5 but not in 4.


Hi Ian,

Fortunately, I got a similar answer in a german mysql newsgroup.
In my queries, there were two left joins and the other table mappings were
made by where statements.
I got the hint to replace the where mappings by inner joins which have to
stand before the left joins and NOT to separate the joins by kommata.
These queries now also work on mysql 4 & 5.
I also read the statement, that this new behaviour should/would be made
backwards-compatible again so old queries would work again. I directly
tried it with the newest mysql version but my queries didn't work.
So I edited the queries like I wrote and now everything is fine.

Many thanks for your answer.
Yours Henri
 
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit!
Featured Websites
Free Space
Free Space
Free Space Free Space
Closed Thread
Tags: , , , , ,




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
nucleus install fails - mysql problems Eric Database 0 05-31-2007 8:47 PM
MySQL Query Cache Not Working: MySQL 5 / Windows XP Good Man Database 0 05-31-2007 8:46 PM
MySQL MaxDB 7.6.00.10 Joins und Subquery Daniel Krämer Database 1 05-31-2007 8:42 PM
SELECT DISTINCT with Joins? Aapo V Database 1 05-31-2007 8:39 PM
DB_DataObject Joins Noel da Costa Pear 1 05-20-2007 6:34 PM


Featured Websites




All times are GMT +1. The time now is 3:09 PM.


Powered by: vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.0.0
Cheap Computers
MK PitStop Copyright 2005 - 2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98