update a set a.UpDownExtent=round(((b.NewValue-b.YesterdayClose)/b.YesterdayClose)*100,3) from BuyLog a left join SumStock b on a.CodeID=b.CodeID where b.States<>0 and a.UserID=1
这句在 SQL Server 里执行很正常,可是在access数据库执行就报错:语法错误(操作符丢失)在查询表达式
请问改如何改正?谢谢!

解决方案 »

  1.   

    ACCESS ADO访问时是JET-SQL  JET-SQL 参考 (如安装OFFICE选择帮助,则直接访问本机) 
    C:\Program Files\Common Files\Microsoft Shared\OFFICE11\2052\JETSQL40.CHM JET-SQL 参考  
    http://download.csdn.net/source/351771 Access使用的是Jet-SQL。  JET SQL 帮助(jet4 access2000)下载地址  
    http://www.access911.net/index.asp?board=8&recordid=75FAB71E&tt=  
      

  2.   

    我看了JET-SQL的语法,left join 是支持的啊。为什么还报错呢?
      

  3.   

    update BuyLog set a.UpDownExtent=round(((b.NewValue-b.YesterdayClose)/b.YesterdayClose)*100,3) 
    from BuyLog a left join SumStock b on a.CodeID=b.CodeID 
    where b.States<>0 and a.UserID=1
    update用直接用表名,再试试
      

  4.   


    update BuyLog set a.UpDownExtent=round(((b.NewValue-b.YesterdayClose)/b.YesterdayClose)*100,3)  
    from BuyLog a left join SumStock b on a.CodeID=b.CodeID  
    where b.States <>0 and a.UserID=1
    这样还是报同样的错!
      

  5.   

    --看你对不匹配的数据没有操作.如下即可
    update BuyLog 
    set a.UpDownExtent=round(((b.NewValue-b.YesterdayClose)/b.YesterdayClose)*100,3)
    from BuyLog a , SumStock b 
    where a.CodeID = b.CodeID and b.States <>0 and a.UserID=1
      

  6.   

    --或者.ACCESS里面是不是用isnull就不知道了.
    update BuyLog 
    set a.UpDownExtent= isnull(select round(((b.NewValue-b.YesterdayClose)/b.YesterdayClose)*100,3) from SumStock b where a.CodeID = b.CodeID and b.States <>0 and a.UserID=1 , a.UpDownExtent)
    from BuyLog a 
      

  7.   


    update BuyLog 
    set a.UpDownExtent=round(((b.NewValue-b.YesterdayClose)/b.YesterdayClose)*100,3)
    from BuyLog a , SumStock b 
    where a.CodeID = b.CodeID and b.States <>0 and a.UserID=1update BuyLog 
    set a.UpDownExtent= isnull(select round(((b.NewValue-b.YesterdayClose)/b.YesterdayClose)*100,3) 
    from SumStock b where a.CodeID = b.CodeID and b.States <>0 and a.UserID=1 , a.UpDownExtent)
    from BuyLog a 
    这两个还是同样报错:语法错误(操作符丢失)在查询表达式
      

  8.   

    update BuyLog set UpDownExtent=round(((b.NewValue-b.YesterdayClose)/b.YesterdayClose)*100,3)  
    from BuyLog a left join SumStock b on a.CodeID=b.CodeID  
    where b.States <>0 and a.UserID=1再试一下!a.UpDownExtent写成UpDownExtent
      

  9.   

    update BuyLog set UpDownExtent=round(((b.NewValue-b.YesterdayClose)/b.YesterdayClose)*100,3)   
    from BuyLog a left join SumStock b on a.CodeID=b.CodeID   
    where b.States  <>0 and a.UserID=1 这样写语法是没有错误的!a.UpDownExtent换成了UpDownExtent
      

  10.   

    to : vchao13还是报错:语法错误 (操作符丢失) 在查询表达式 'round(((b.NewValue-b.YesterdayClose)/b.YesterdayClose)*100,3)   
    from BuyLog a left join SumStock b on a.CodeID=b.CodeID' 中。
      

  11.   

    我刚才发的sql句没有语法错误,要不你这样,你把.ACCESS数据库导入sql数据库,然后再用上面的语句查询,看看有什么提示,会不会是字段有错,还是ascess不支持round函数。。试试吧!要不不知道错在哪的
      

  12.   

    这句是我从sqlserver转到access的,在sqlserver上完全正确,可是在access上就报错!总是报语法错误!
      

  13.   

    报错,因为你的写法不对。access里的连表更新的语法为:update a inner join b on set .. where ..这跟t-sql是有区别的。语句很简单,我就不写了,你自己对照jet sql的语法更改一下语句就可以了。参见。
    http://topic.csdn.net/u/20080315/23/2263bf35-cade-4718-a5fc-2d677efadacf.html
      

  14.   

    fcuandy 正确
    正确写法为update BuyLog a left join SumStock b on a.CodeID=b.CodeID 
    set a.UpDownExtent=round(((b.NewValue-b.YesterdayClose)/b.YesterdayClose)*100,3) 
    where b.States<>0 and a.UserID=1
    感谢!