zoukankan      html  css  js  c++  java
  • mysql 批量添加 更新

        /**
         * 批量添加
         */
        const INNER_UCENTER_USER_BASE_SQL = <<<EOF
            INSERT INTO ucenter_user_base(
               user_name,nice_name,avatar,created,modified
            )
            SELECT
               UcenterImport.card_no,UcenterImport.card_no,"/images/avatar.png",?,?
            FROM
                ucenter_import AS UcenterImport
                LEFT JOIN ucenter_user_base AS UcenterUserBase ON UcenterUserBase.user_name = UcenterImport.card_no
            WHERE
                UcenterUserBase.user_name IS NULL AND UcenterImport.batch_id = ?
    EOF;
    
        /**
         * 批量更新
         */
        const UPDATE_UCENTER_IMPORT_SQL = <<<EOF
                UPDATE
                    ucenter_import AS UcenterImport
                    INNER JOIN ucenter_user_base AS UcenterUserBase ON UcenterUserBase.user_name = UcenterImport.card_no
                SET
                    UcenterImport.user_id = UcenterUserBase.user_id
                WHERE
                    UcenterImport.batch_id = ?
    EOF;
    
    UPDATE categories SET 
    display_order = CASE id 
            WHEN 1 THEN 3   当id等于1 的时候 display_order 更新为3
            WHEN 2 THEN 4 
            WHEN 3 THEN 5 
    END, 
    title = CASE id 
            WHEN 1 THEN 'New Title 1'
            WHEN 2 THEN 'New Title 2'
            WHEN 3 THEN 'New Title 3'
    END
    WHERE id IN (1,2,3);
    

      

      

    UPDATE `member` SET score = (CASE WHEN score IS NOT NULL THEN score = 0 ELSE score = 1 END) where id =1;
    

      

  • 相关阅读:
    Java 集合(静态导入)
    Java 集合 (Collections、Arrays)
    Java 异常
    Java 多态
    Java 继承

    内网服务器配置访问公网
    替换centos的原生yum源为阿里云yum源
    centos7安装杀毒软件ClamAV
    linux程序名称带devel跟不带的区别
  • 原文地址:https://www.cnblogs.com/sanqiyi/p/7920710.html
Copyright © 2011-2022 走看看