zoukankan      html  css  js  c++  java
  • Mysql Mybatis 使用相关知识

    You can't specify target table '表名' for update in FROM clause (来源

    翻译为:不能先select出同一表中的某些值,再update这个表(在同一语句中)
    解决办法:将SELECT出的结果再通过中间表SELECT一遍

    UPDATE result 
    SET StudentResult=StudentResult+5
    WHERE StudentResult in (  
      (SELECT  res.StudentResult
      FROM student stu JOIN result res on res.StudentNo=res.StudentNo 
      where res.StudentResult=53 and stu.GradeId=(SELECT GradeId FROM grade WHERE GradeName='大一')
      )
    )
    
    需要改为
    
    UPDATE result 
    SET StudentResult=StudentResult+5
    WHERE StudentResult in (  
      SELECT a.StudentResult from
      (SELECT  res.StudentResult
      FROM student stu JOIN result res on res.StudentNo=res.StudentNo 
      where res.StudentResult=53 and stu.GradeId=(SELECT GradeId FROM grade WHERE GradeName='大一')
      ) AS a
    )
    

    mysql 类型为 bit 时的操作

    UPDATE `xxx` SET `xxx`=b'0' WHERE `id`=1;
    

    mybatis异常:The content of elements must consist of well-formed character data or markup的解决方法 (来源

    不是格式良好的xml,也就是我们的书写格式有误,常见的就是 < 符号 需要转义

    select * from t where time > #{endTime} <![CDATA[ and time < #{startTime} ]]>
    

    mybatisplus 使用 script 解析list

    @Select({
            "<script>",
            "update xx set vv= #{vv} where id in " ,
            "<foreach collection='idList' item='data' open='(' separator=',' close=')'>",
            "#{data}" ,
            "</foreach>" ,
            " and cc<![CDATA[ <> #{cc} ]]>",
            "</script>"})
  • 相关阅读:
    (离线算法 LCA) hdu 2874
    (树形DP) hdu 4118
    (树的重心) poj 1655
    (线性基) bzoj 2115
    (线性基) bzoj 2460
    (边双联通+树直径) hdu 4612
    (拓扑图+DP) poj 3249
    (求割点和除去割点后的联通块数目) poj 1523
    (边双联通) poj 3352
    (DP求最长路) hdu 4607
  • 原文地址:https://www.cnblogs.com/cuiyf/p/14813867.html
Copyright © 2011-2022 走看看