zoukankan      html  css  js  c++  java
  • SQL update 多表连接方法

    SQL Update多表联合更新的方法
    (1) sqlite 多表更新方法
    //----------------------------------
    update t1 set col1=t2.col1
    from table1 t1
    inner join table2 t2 on t1.col2=t2.col2
    这是一个非常简单的批量更新语句 在SqlServer中支持此语法 sqlite中却不支持
    
    
    sqlite中可转换为 如下语法 
    update table1 set col1=(select col1 from table2 where col2=table1.col2)
    
    
    update ta_jbnt_tzhd_pht_Area_xiang set t1=(select sys_xzqhdm.name from sys_xzqhdm 
     where t2=sys_xzqhdm.code) 
    
    
    (2) SQL Server 多表更新方法
    //----------------------------------
    SQL Server语法:UPDATE { table_name WITH ( < table_hint_limited > [ ...n ] ) |
    view_name | rowset_function_limited } SET { column_name = { expression | DEFAULT
    | NULL } | @variable = expression | @variable = column = expression } [ ,...n ]
    { { [ FROM { < table_source > } [ ,...n ] ] [ WHERE < search_condition > ] } | [
    WHERE CURRENT OF { { [ GLOBAL ] cursor_name } | cursor_variable_name } ] } [
    OPTION ( < query_hint > [ ,...n ] ) ]
    
    
    SQL Server示例: update a set a.gqdltks=b.gqdltks,a.bztks=b.bztks from
    landleveldata a,gdqlpj b where a.GEO_Code=b.lxqdm
  • 相关阅读:
    20150324--Mysql索引优化-02
    20150324--Mysql索引优化-01
    20150323--memcache-02
    20150323--memcache-01
    轮播效果/cursor
    事件监听和事件概念
    BOM与DOM操作
    for循环语句/命名函数
    数组/控制语句
    数据类型转换/正则表达式
  • 原文地址:https://www.cnblogs.com/xiaowie/p/9328547.html
Copyright © 2011-2022 走看看