如何用PHP写段小程序实现我以下的需求?
我就三个字段,其中两个字段在一个表A。另外一个字段在一个表B,我想把这两个表中的三个字段的内容更新到第三个表C中,怎么写

解决方案 »

  1.   

     (不要高估你的汉语表达能力或者我的汉语理解能力)
       建议你列出你的表结构,并提供测试数据以及基于这些测试数据的所对应正确结果。
       参考一下这个贴子的提问方式http://topic.csdn.net/u/20091130/20/8343ee6a-417c-4c2d-9415-fa46604a00cf.html
       
       1. 你的 create table xxx .. 语句
       2. 你的 insert into xxx ... 语句
       3. 结果是什么样,(并给以简单的算法描述)
       4. 你用的数据库名称和版本(经常有人在MS SQL server版问 MySQL)
       
       这样想帮你的人可以直接搭建和你相同的环境,并在给出方案前进行测试,避免文字描述理解上的误差。   
      

  2.   


    update c set c1=a.c1,c2=a.c2,c3=b.c1 where a.id=c.id and b.id=c.id;
      

  3.   

    错误
    SQL 查询: UPDATE pre_forum_post SET pid = excms_contents.contentis,
    fid = excms_contents.channelid,
    subject = excms_contents.title,
    message = excms_contents_articles.body WHERE excms_contents.contentid = pre_forum_post.pid AND excms_contents_articles.contentid = pre_forum_post.pid MySQL 返回: #1054 - Unknown column 'excms_contents.contentid' in 'where clause' 
      

  4.   

    你这个是SQL SERVER的T-SQL语法。MYSQL中不一样!update c inner join b using (id) inner jion a using(id)
    set c.col=a.col+b.col;