简体   繁体   中英

Mysql 4.0.30 Error 1046… but working on 5.5!

On our dev-server we've got MySql version 5.5, but on production server (from aruba.it) we've Mysql 4.0.30. The SQL query that cause problem is:

SELECT r.iduser,ra.desapp, r.cognom,f.desfig, r.fl_dip, (Select sum(o.numore)/8 From OreConsuntive o, Prjtask pt, Prjprogetti pp, Prjordini po Where o.IDuser = '54'and o.dt_cns >= '20110101' and o.dt_cns <= '20110131' and o.codcop='F00' and o.codtsk=pt.codtsk and pt.codprj=pp.codprj and pp.codord=po.codord and left(po.cliatt,3)<>'CSA' group by o.numore) as TOTGIORNIFATTMESE FROM Risorse r, Figure f, RisorsaArea ra WHERE r.codfig=f.codfig AND r.areapp=ra.codapp AND r.IDuser='54' ORDER BY r.areapp desc

I'll try to execute only this part

Select sum(o.numore)/8 From OreConsuntive o, Prjtask pt, Prjprogetti pp, Prjordini po Where o.IDuser = '54'and o.dt_cns >= '20110101' and o.dt_cns <= '20110131' and o.codcop='F00' and o.codtsk=pt.codtsk and pt.codprj=pp.codprj and pp.codord=po.codord and left(po.cliatt,3)<>'CSA' group by o.numore

and it seems to work! Can the problem be caused by the annidated select ? How con I modify my query to get a working one on mysql 4.0.30 ?

Thanks a lot! Davide

MySQL versions prior to 4.1 do not support subqueries. You will have to rewrite your query to avoid that.

Unfortunately, I can't easily tell how to do that in your case, but try reading http://dev.mysql.com/doc/refman/4.1/en/rewriting-subqueries.html - it may help you to rewrite it.

I don't know your particular host, but if they cannot upgrade you to a newer MySQL, you should try to downgrade your development server to run the same version as your production server - a lot of things have changed since 4.0, and catching them early might be a good idea.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM