008--MyBatics相关的SQL书写

1.1 Select参数Map中带有List和普通参数,并且伴随>,<,=,like判断,标签

     

1.2 Select直接使用where(貌似不能使用'0'把数字包起来)

    

1.3 Select如果在一个范围内就转化成ture,否则就是false

        SELECT DISTINCT
            pdCode,
            pdName,
        if(pdCode in  (
        
                #{pdCode}
         ),'true','false')  isSelected
        FROM
            a_pd
        WHERE pmSequence = 10086

1.4 Select多个判断“或/且”关系

    
    SELECT
        
    FROM student

1.6 Select进行查找

      
          
          
        
            
        
       

    
     

1.7 Select in (List集合)

  

1.8 Select in (Array数组)

  

2.1 Insert批零数据的导入(SQL)

    
        INSERT INTO a_coupon_ctbr(
            cptSequence,
            branchSequence,
            cpmrSequence
        )VALUES
        
            (
            #{couponBranch.cptSequence},
            #{couponBranch.branchSequence},
            #{couponBranch.cpmrSequence}
            )
        
    

2.2 Insert批零数据的导入(JAVA)

    public static void main(String[] args) {
        int num = 598;//总数量
        int batch = 200;//批量每次操作的个数
        int count = num/batch + 1;//一定会操作的次数
        int tempNum = 0;//当前操作的索引
        System.out.println("请求的次数:"+count);
        for (int i = 0; i < count; i++) {
            for (int j = 0; j < batch; j++) {
                tempNum = i*batch+j; 
                if (tempNum"+tempNum);
                }
            }
            System.out.println("已经成功打印100次");
        }
    }

3.1 Update更新语句使用trim去除“,”

    
        UPDATE a_coupon_cpmr
            
                batch_no = #{batch_no},
                cpmrType = #{cpmrType},
            
        WHERE
            cpmrSequence = #{cpmrSequence}
    

3.2 Update更新语句直接设置

    
        UPDATE a_coupon_cpt
        SET
            cptStatus = 'D'
        WHERE cptSequence = #{cptSequence}
    

4.Delete删除语句

    
        DELETE FROM 
            a_coupon_ctur
        WHERE
            cptSequence = #{cptSequence}
    

应用格式

1234980

123456790

2345

23458709
  • 234980
  • 1234576890
  • 123476980

小美女

表格使用

Tables Are Cool
col 3 is right-aligned $1600
col 2 is centered $12
zebra stripes are neat $1

123457-=


你可能感兴趣的:(008--MyBatics相关的SQL书写)