oracle语句是: select a.amid as pageid,a.asid as areaid,a.adid as adnum,a.endtime,a.ispay,nvl(b.hitscount,0) as hitscount,a.title
from Ads  a 
left join 
(select areaid,sum(hitscount) as hitscount,adnum from Adscount 
where areaid=#intval1# and recordtime >= #strval1# and recordtime <= #strval2#
group by areaid,adnum) b
 on a.asid=b.areaid and a.adid=b.adnum
where  a.asid = #intval1# and a.isdel='0' 
order by a.orderid desc
我现在用的数据库是Mysql 请问改怎么转!谢谢!

解决方案 »

  1.   

    select a.amid as pageid,a.asid as areaid,a.adid as adnum,
           a.endtime,a.ispay,IFNULL(b.hitscount,0) as hitscount,a.title
    from Ads  a 
       left join 
       (
           select areaid,sum(hitscount) as hitscount,adnum from Adscount 
           where areaid=XX and recordtime >= 'strval1' and recordtime <= 'strval2'
            group by areaid,adnum
        ) b
    on a.asid=b.areaid and a.adid=b.adnum
    where  a.asid = XX and a.isdel='0' 
    order by a.orderid desc;
      

  2.   

    就只要改这“IFNULL(b.hitscount,0) as hitscount” 一处就可以啦是吗?
      

  3.   

    select a.amid as pageid,a.asid as areaid,a.adid as adnum,a.endtime,a.ispay,nvl(b.hitscount,0) as hitscount,a.title
            from Ads  a 
            left join 
            (select areaid,sum(hitscount) as hitscount,adnum from Adscount 
            where areaid=#intval1# and recordtime >= #strval1# and recordtime <= #strval2#
            group by areaid,adnum) b
             on a.asid=b.areaid and a.adid=b.adnum
            where  a.asid = #intval1# and a.isdel='0' 
            order by a.orderid desc
    #intval1#:intval1是变量名?areaid字段类型?
      

  4.   

    是的NVL是oracle 中的函数,在mysql目前版本中还不被支持。
      

  5.   

    oracle的函数nvl在mysql里对应是 ifnull