问题描述
1 varchar 排序
当前数据库中的类型时varchar
当排序的时候会出现问题 ,所以 在排序的时候使用 CAST(value AS DECIMAL) 用于转换成数据进行排序
完整的sql语句如下:SELECT * from data WHERE range_code='CV02.01.102' ORDER BY CAST(value AS DECIMAL)
问题描述
错误提示:You can‘t specify target table for update in FROM clause
原因分析:
根据Mysql官方文档的描述:
You cannot update a table and select directly from the same table in a subquery. You can work around this by using a multi-table update in which one of the tables is derived from the table that you actually wish to update, and referring to the derived table using an alias:
即:不能在子查询中更新表并直接从同一表中进行选择。您可以通过使用多表更新来解决此问题,其中一个表是从您实际希望更新的表派生的,并使用别名引用派生表
说人话就是当你更新某一张表A时,where后面的条件就不能直接包含(select XXX from A)这样的子句,至于原因官方则没说
个人方案:没有什么是套一层不能解决的,如果有,那就套两层:
UPDATE items
SET retail = retail * 0.9
WHERE id IN
(select id from (SELECT id FROM items
WHERE retail / wholesale >= 1.3 AND quantity > 100) s);
问题描述
错误提示:
Caused by: java.lang.NumberFormatException: For input string: "E"
原因分析:
ognl 解析导致的问题 ,这里 'E' 将被认为是 char 类型。
个人方案:
1.改为:test="name eq 'E'.toString()"
2.原因是OGNL语法的问题:
这里 'E' 将被认为是 char 类型,但是 'EE' 或者 "E" 将被作为 String类型。所以我们可以用转义:<if test="name == "E"">
3.或者将 <if test="name == 'E'"> 改为 <if test='name == "E"'>。