随笔分类 -  Mysql

group_concat() 函数用法
摘要:没有办法在语句中直接使用if条件(存储过程可以),所以可以利用下面方法实现 方法1: SELECT *FROM ( SELECT *, 1 as source_table FROM hljtxeip_workday_holiday WHERE `year` = YEAR ( NOW()) AND ` 阅读全文
posted @ 2024-11-04 16:00 20211103 阅读(18) 评论(0) 推荐(0)
摘要:https://mp.weixin.qq.com/s/lqtvh9QkfwElkKiCiOmZeg 阅读全文
posted @ 2024-10-12 08:42 20211103 阅读(10) 评论(0) 推荐(0)
摘要:这条MySQL语句中使用了substring_index函数来处理training_pictures列的数据。下面是该函数的具体用法: substring_index(str,delim,count):这个函数会返回字符串str中第count个出现的分隔符delim之前的所有字符,或者之后的所有字符 阅读全文
posted @ 2024-07-30 09:14 20211103 阅读(26) 评论(0) 推荐(0)
摘要:https://mp.weixin.qq.com/s/MK3P5xzbs38QAjjdt-Zz5Q 阅读全文
posted @ 2024-07-26 15:15 20211103 阅读(11) 评论(0) 推荐(0)
摘要:SELECT attachment FROM hljtxeip_draft_notice select a.ID,substring_index(substring_index(a.attachment,',',b.help_topic_id+1),',',-1) from hljtxeip_dra 阅读全文
posted @ 2024-07-25 14:04 20211103 阅读(13) 评论(0) 推荐(0)
摘要:SHOW OPEN TABLES WHERE In_use > 0; SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS WHERE LOCK_TABLE = 'hljtxeip/hljtxeip_personworkrecord'; SELECT ID, U 阅读全文
posted @ 2024-07-11 13:57 20211103 阅读(9) 评论(0) 推荐(0)
摘要:INSERT INTO a( aax, aaz) ( SELECT aax, aaz FROM b WHERE x IN ( 1,2,3 ) ); 类似一个这种数据迁移的sql 如果用了where 条件请在条件上 完全遵从数据格式 如果偷懒 直接输入数字类型的 1,2,3 的话 就会报错runcat 阅读全文
posted @ 2023-12-29 14:10 20211103 阅读(178) 评论(0) 推荐(0)
摘要:https://blog.csdn.net/carefree31441/article/details/119563685 阅读全文
posted @ 2023-10-08 13:32 20211103 阅读(17) 评论(0) 推荐(0)
摘要:https://blog.csdn.net/qq_36800514/article/details/115380100 -- 阅读权限 全239 部分9 select * from hljtxeip_institution where state = 1 and deleteState = 0 an 阅读全文
posted @ 2023-10-08 11:44 20211103 阅读(407) 评论(0) 推荐(0)
摘要:WITH RECURSIVE subordinates AS ( SELECT * FROM sys_dept WHERE dept_id = 1 -- 这里以员工ID为1为例 UNION ALL SELECT e.* FROM sys_dept e INNER JOIN subordinates 阅读全文
posted @ 2023-09-14 16:00 20211103 阅读(42) 评论(0) 推荐(0)
摘要:1. current_timestamp 2. current_time 3.current_data 4. now() 5. curdate() 6.curtime() 将当前时间插入数据库 insert into t_login(user_id,login_time) values (1,CUR 阅读全文
posted @ 2021-11-15 16:11 20211103 阅读(587) 评论(0) 推荐(0)
摘要:substring_index(str,delim,count) str:要处理的字符串 delim:分隔符 count:计数 例子:str=www.wikidm.cn substring_index(str,'.',1) 结果是:www substring_index(str,'.',2) 结果是 阅读全文
posted @ 2021-11-15 10:18 20211103 阅读(95) 评论(0) 推荐(0)
摘要:mysql中将多行数据合并成一行数据 一个字段可能对应多条数据,用mysql实现将多行数据合并成一行数据 修改过后的sql语句,查询后如图所示: 对分组结果筛选后合并 ** 对分组结果筛选排序后合并 基本语法:group_concat([DISTINCT] 要连接的字段 [Order BY 排序字段 阅读全文
posted @ 2021-11-08 18:14 20211103 阅读(3643) 评论(0) 推荐(0)