• MYSQL用一个表中的字段批量更新另一个表中的字段


    select ta.id,ta.parent_id,ta.name,ta.level, mr.id as r_id,mr.parent_id as r_pid,mr.name as r_name,mr.type as r_type,mr.provice_id as r_provice_id from test_movhome.area ta, movhome.region mr where ta.name = mr.name
    
    
    # 批量替换,用一个表中的字段 更新 另一个表中的字段
    update test_movhome.cinema a inner join 
    (select ta.id,ta.parent_id,ta.name,ta.level, mr.id as r_id,mr.parent_id as r_pid,mr.name as r_name,mr.type as r_type,mr.provice_id as r_provice_id from test_movhome.area ta, movhome.region mr where ta.name = mr.name) b 
    on a.region_id = b.r_id set a.region_id = b.id
    
    
    # 批量替换,用一个表中的字段 更新 另一个表中的字段
    update test_movhome.cinema a, 
    (select ta.id,ta.parent_id,ta.name,ta.level, mr.id as r_id,mr.parent_id as r_pid,mr.name as r_name,mr.type as r_type,mr.provice_id as r_provice_id from test_movhome.area ta, movhome.region mr where ta.name = mr.name) b 
    set a.new_region_id = b.id, a.other_filed = b.other_filed
    where a.region_id = b.r_id
    
    # 批量设置一个表中的字段为一个固定的值
    update test_movhome.cinema a set a.new_region_id = 0
  • 相关阅读:
    比较字符串
    angular 兼容ie7 bootstrap2兼容ie6
    angular $watch
    CSS超过指定的宽度加省略号
    出去html中的标签
    andriod自定义视图
    andriod创建用户界面(1)
    安卓Activity生命周期(转)
    迷你版mvc框架执行过程
    【03月04日】A股滚动市盈率PE历史新低排名
  • 原文地址:https://www.cnblogs.com/macliu/p/12274169.html
Copyright © 2020-2023  润新知