SQL
UTF杠8
共同进步
展开
-
MySQL ERROR:1153 的解决方法
1153 的解决方法报错:I had the same problem, with an 8gb .sql file. I didn't have any luck with --max_allowed_packet;解决方法如下:1.在终端中使用MySQL的root用户登录MySQL;2.执行命令:1). set global max_allowed_packet=100...原创 2018-11-19 18:12:46 · 3172 阅读 · 0 评论 -
sql 查询 数据库中的重复数据
闲言少叙:直接上代码SELECT out_id,count(*) AS count, created_at from parana_sku_orders WHERE shop_id=6 GROUP BY out_id HAVING count>1 ORDER BY created_at DESC;原创 2018-11-19 18:09:14 · 1770 阅读 · 2 评论 -
Mybaits 中 <if>判断 传入的字符串是否 相等 的 坑
两种方式进行字符串相等的判断!有问题代码<if test="a=='x'"></if>这样是不行的我就纳闷了,变量传过来没有问题啊原因:因为mybatis映射文件,是使用的ognl表达式。 正确方法;1.<if test="a=='x'.toString()">a 为字段 2.<if test= 'a=="x&quo原创 2018-11-19 18:24:27 · 343 阅读 · 0 评论 -
Mysql 数据库中数字相减 出现负数时sql 语句报错
原因:两个字段都是无符号的,UNSINED 需要 通过 cast(‘字段’as SINED) 或者 convert(‘字段’, SINED) 两个函数 将字段转换为有符号的SINED 状态。 使用 CAST: CAST ( expression AS data_type ) 使用 CONVERT: CONVERT (data_type[(length)], ex...原创 2018-11-19 18:27:42 · 6650 阅读 · 0 评论 -
SQL 中 union 和 union all 区别
select * from(select userid from userTable where userid in (201,202)Unionselect userid from userTable where userid in (101,102,301,302)) as aorder by userid效率:UNION和UNION ALL关键字都是将两个...原创 2018-11-19 18:34:45 · 134 阅读 · 0 评论 -
Spring boot 连接mongodb 报错 Command failed with error 18: 'Authentication failed.'
问题描述:root 用户访问不了,mongodb 下的其他的collection 集合,报错:Can not catch com.mongodb.MongoCommandException: Command failed with error 18: 'Authentication failed.' 解决方式:在需要连接的集合上创建用户db.createUser({u...原创 2018-11-27 15:48:59 · 13316 阅读 · 0 评论 -
Mysql 主从复制 (一)
一、主服务器 配置 my.ini 或 my.conf 作如下修改:# Binary Logging. ===========================开始===========================================log-bin=mysql-bin-1binlog-format=Mixed# Error Logging.log-error="LAP...原创 2019-08-08 16:40:25 · 135 阅读 · 0 评论 -
Mysql 数据迁移引发的sql 双重 for 循环 存储过程的编写 (包含Mysql 5.7 JDBCType 为 json 的字段的操作 )
这次数据迁移主要涉及的数据为,从一张表迁移到另一张表,同时将一列 JDBCType JSON (JsonArray)的数据拆分成多个字段,这里用到了存储过程,其中用到了双重循环。delimiter // #定义标识符为双斜杠drop procedure if exists outFor; #如果存在test存储过程则删...原创 2019-09-09 13:26:20 · 374 阅读 · 0 评论 -
一次复杂查询引发 的 sql 优化问题
场景:从blob 中 读取gps信息 数据量达到几百万,需要在一张表中查询出每台车的最新的 gps 信息;复杂原因:表里边的数据每个 vin 有多条数据 ,time 字段不唯一。SELECT * FROM car_gps a INNER JOIN (SELECT MAX(id) as id FROM car_gps GROUP BY vin) as b ON a.id = b.i...原创 2019-09-09 15:10:08 · 426 阅读 · 0 评论