h2 count+orderBy踩坑
发表于|更新于
|浏览量:
过度的爱情追求,必定会降低人本身的价值——培根
mysql里两个都可执行

h2执行第二条会报错

因此不要在h2写count时使用orderBy
相关推荐
2023-02-28
mysql去掉decimal末尾的0
我思故我在——笛卡尔 我们可以使用0+CAST(字段 AS CHAR)来去除decimal末尾的0 如果已经是CHAR类型,那就直接使用0+字段即可
2020-12-27
mysql日期函数
不怨天,不尤人。——《论语》 转,原文 一、MySQL 获得当前日期时间 函数1,获得当前日期+时间(date + time)函数:now(): 12select now(); 结果:2008-08-08 22:20:46 2,获得当前日期+时间(date + time)函数:sysdate()sysdate() 日期时间函数跟 now() 类似,不同之处在于:now() 在执行开始时值就得到了, sysdate() 在函数执行时动态得到值; 12select sysdate(); 结果:2008-08-08 22:20:46 3,MySQL 获得当前时间戳函数:current_timestamp, current_timestamp(): 12select current_timestamp, current_timestamp(); 结果:2008-08-09 23:22:24 , 2008-08-09 23:22:24 二、MySQL 日期转换函数、时间转换函数1,MySQL Date/Time to Str(日期/时间转换为字符串)函数:da...
2020-07-01
避免循环操作数据库
今天看到公司实习写的代码。。。 1234567for (Long id : ids) { //查询 TbGoods tbGoods = goodsMapper.selectByPrimaryKey(id); tbGoods.setIsDelete("1"); //逻辑删除 //修改 goodsMapper.updateByPrimaryKey(tbGoods); } 这是,循环操作数据库?! 晕。。。希望以后不再看到这样的代码。。。 我给他写了个mapper.xml里的sql,用 where id in()替代,这样只有一条sql语句了 1234567891011<!-- 根据主键查询数据 --> <select id="selectByPrimaryKeys" resultMap="BaseResultMap" parameterType="list&q...
2022-02-22
mysql导出导入
成熟意味着停止展示自己并学会隐藏自己。——《失踪的孩子》 官方文档:https://dev.mysql.com/doc/refman/8.0/en/backup-and-recovery.html 我们可以使用mysql自带的导出工具mysqldump进行导出,我们进入到mysql的bin目录,运行命令 1mysqldump -u[用户名] -p --default-character-set=[编码格式] --databases [数据库名] > [导出路径] 例如我此处的: 1mysqldump -uroot -p --default-character-set=utf8 --databases test > D:\file\tmp\xxx.sql 输入完毕后需要输入密码,我们输入就行了 然后我们可以在mysql客户端中使用source命令,首先连接mysql 1mysql -uroot -p 输入密码后我们切换到想导入的数据库 1use test; 然后使用source 1source D:/file/tmp/xxx.sql; 注意反斜杠转义问题...
2022-02-10
mysql数据库信息函数
我将仇恨写在冰上,然后期待太阳的升起。——加西亚马尔克斯 打开mysql官方文档:Information Functions 可以看到mysql查询库表信息的函数 Name Description BENCHMARK() Repeatedly execute an expression CHARSET() Return the character set of the argument COERCIBILITY() Return the collation coercibility value of the string argument COLLATION() Return the collation of the string argument CONNECTION_ID() Return the connection ID (thread ID) for the connection CURRENT_ROLE() Return the current active roles CURRENT_USER(), CURRENT_USER...
2023-02-16
mysql having报错this is incompatible with sql_mode=only_full_group_by
该得到荣誉却未得到,比不该得到荣誉而得到要好得多。——马克·吐温 今天遇到个报错 发现原来是MYSQL 8不支持在sql_mode包含only_full_group_by时(默认包含) HAVING的条件里有 非聚合字段 以外的字段 文档: ONLY_FULL_GROUP_BY Reject queries for which the select list, HAVING condition, or ORDER BY list refer to nonaggregated columns that are neither named in the GROUP BY clause nor are functionally dependent on (uniquely determined by) GROUP BY columns. A MySQL extension to standard SQL permits references in the HAVING clause to aliased expressions in the select list. The ...
