当前位置: 代码迷 >> PowerDesigner >> sql话语update 可以通过多表条件,而更新数据
  详细解决方案

sql话语update 可以通过多表条件,而更新数据

热度:1628   发布时间:2013-02-26 00:00:00.0
sql语句update 可以通过多表条件,而更新数据
SqlServer2005 下可以
update
A
set A.c_limitDate=B.ReplyDeadline from (SELECT *
    FROM visit_entries AS b
    WHERE (SELECT COUNT(*) FROM visit_entries WHERE code=b.code)=1 )B
inner join (SELECT *
    FROM hdzx_question as a
    WHERE (SELECT COUNT(*) FROM hdzx_question WHERE c_qusno=a.c_qusno)=1
)A on B.code=A.c_qusno and A.c_limitDate is null and A.c_qusStatus=4

以下是对应的2000:
update
A
set A.c_limitDate=B.ReplyDeadline from (SELECT *
    FROM visit_entries AS b
    WHERE (SELECT COUNT(*) FROM visit_entries WHERE code=b.code)=1 )B
    inner join  hdzx_question as A on B.code=A.c_qusno and A.c_limitDate is null and A.c_qusStatus=4
  相关解决方案