现在有两张表t_soft1,t_soft2,这两张表有两个相同名称的列id,softlinks,其中id为主键并且两张表的id列数据完全相同。我现在想把t_soft2的softlinks列的数据覆盖t_soft1的数据。在MSSql我用下面的语句成功实现,但在MySql环境中用PhpAdmin就报错,请问是什么原因?
update t_soft1 set softlinks = t_soft2.softlinks from t_soft1,t_soft2 where t_soft1.id = t_soft2.id

解决方案 »

  1.   

    update t_soft1,t_soft2 where t_soft1.id = t_soft2.id
    set t_soft1.softlinks = t_soft2.softlinks 
      

  2.   

    还是报错哦。
    #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where t_soft1.id = t_soft2.id set t_soft1.softlinks = t_soft2.softlinks' at line 1 
      

  3.   

    update t_soft1,t_soft2 set t_soft1.softlinks = t_soft2.softlinks
    where t_soft1.id = t_soft2.id 
      

  4.   

    update t_soft1 set softlinks = t_soft2.softlinks from t_soft1,t_soft2 where t_soft1.id = t_soft2.id这个MSSQL的写法,是在mysql里不支持的,改成如下:update t_soft1 inner join t_soft2 on t_soft1.id = t_soft2.id
    set t_soft1.softlinks = t_soft2.softlinks 或update t_soft1,t_soft2 set t_soft1.softlinks = t_soft2.softlinks 
      where t_soft1.id = t_soft2.id 
      

  5.   


    执行成功了,至为感谢,能告诉我为什么会出现这样的情况吗?Mysql和Mssql在语句的书写方面有什么不一样吗?
      

  6.   

    主要是语法格式不同,可以看看MYSQL的HELP
      

  7.   

    update t_soft1 set softlinks = t_soft2.softlinks from t_soft2 where t_soft1.id = t_soft2.id 
     
     
    你的更新数据来自表2 所以from 后面只要一个表2就可以了