zoukankan      html  css  js  c++  java
  • mysql sql 使用记录

    1. 修改字符集:

    查看数据库字符集
    show VARIABLES like 'character%';
    
    ALTER TABLE  yljg DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
        
    修改数据库字符集
    ALTER TABLE  dept DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;
        
        
    查看    列字符集
    SHOW FULL COLUMNS FROM dept;
        
    SHOW FULL COLUMNS FROM yljg;
        
    修改列字符集
    ALTER TABLE yljg CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;

    2. left join  跨表update, 表内互相update

    SELECT * FROM yljg t left join dept B on t.JGZDYBM = B.DEPTCODE
    WHERE B.parentcode != 0 AND t.xzqhdm IN ('370724' , ' 370725', '370789')
        
    SELECT * from dept WHERE parentcode != '0'
        
        
    UPDATE yljg t, dept B SET t.SJJGBM = B.PARENTCODE 
        
    WHERE t.JGZDYBM = B.DEPTCODE AND  xzqhdm IN ('370724' , ' 370725', '370789')
            
    SELECT * FROM yljg WHERE xzqhdm IN ('370724' , ' 370725', '370789') AND SJJGBM != '0'
        
        
    UPDATE yljg t SET sjjgid = (SELECT JGMC FROM yljg m WHERE t.SJJGBM = m.JGZDYBM) WHERE  t.SJJGBM != '0' AND t.xzqhdm IN ('370724' , ' 370725', '370789')
    UPDATE yljg t SET xzjddm = (SELECT xzjddm FROM yljg m WHERE t.SJJGBM = m.JGZDYBM) WHERE  t.SJJGBM != '0' AND t.xzqhdm IN ('370724' , ' 370725', '370789')
    UPDATE yljg t SET xzjdmc = (SELECT xzjdmc FROM yljg m WHERE t.SJJGBM = m.JGZDYBM) WHERE  t.SJJGBM != '0' AND t.xzqhdm IN ('370724' , ' 370725', '370789')
  • 相关阅读:
    jenkins for xcode
    时间你懂的,
    插件,
    basic ,token添加
    上火啊,替换字符串,HTML,
    shell
    不可深究啊,
    看着 自己都感觉 恶心的代码,
    Tab切换效果
    jar -- java文档归档工具
  • 原文地址:https://www.cnblogs.com/leolzi/p/14040801.html
Copyright © 2011-2022 走看看