mysql汇总

一、多个模糊条件查询 regexp

1、group_concat 连接 distinct 去重 SEPARATOR ',' 逗号分割

select FIELD_NAME 字段中文名,GROUP_CONCAT(DISTINCT FIELD_CODE SEPARATOR ',') 字段英文名 from da_dp_table_field where FIELD_NAME regexp '用户编码|客户编码' and DEL_FLAG=0 group by FIELD_NAME;

2、if(type='',1,null)

select crt_user,crt_name,count(IF(type ='更新',1, null)) '更新',

count(IF(type ='订阅',1, null)) '订阅',count(IF(type ='上架',1, null)) '上架',

count(IF(type ='注册',1, null)) '注册' from da_assets_operation_log_book where tenant_id in ('') and create_timeBETWEEN '2023-10-08 23:59:59' AND '2023-10-16 23:59:59' group by tenant_id ;

if(条件,满足,不满足)

SELECT

t2.TENANT_ID as tenantId,

t4.TITLE as title,

t6.DATA_CODE as dataCode,

t4.ASSETS_ID as assetsId,

t4.ASSETS_STAGE

from da_assets t2

inner join da_dp_field t1 on t1.ID = t2.TABLE_OID AND t2.DEL_FLAG = '0' AND t1.DEL_FLAG = '0'

inner join (SELECT IF (ISNULL( t1.ASSETS_VERSION_ID ),( SELECT tt.ID FROM da_assets_version tt WHERE t1.ID = tt.ASSETS_ID AND tt.ASSETS_STAGE = '0' ),t1.ASSETS_VERSION_ID) AS "versionId",t1.ID AS "id" FROM da_assets t1 WHERE t1.CLASSES_ID = '7') t3 on t2.ID = t3.id

inner join da_assets_version t4 on t3.versionId = t4.ID

inner join da_dataset t5 on t4.DATASET_ID = t5.ID

inner join da_dp_field_current t6 on t5.DP_VERSION = t6.ID

inner join da_assets t7 on t1.ASSETS_ID = t7.ID

inner join da_dp_table t8 on t8.OID = t7.TABLE_OID GROUP BY t4.ASSETS_ID;

3、 json解析

t5.CONTENT ->> ' . P R I V C O L 0 01 9 ′ j s o n 包着解析 t 3. C O N T E N T − > > ′ .PRIV_COL_0019' json包着解析 t3.CONTENT ->> ' .PRIVCOL0019′json包着解析t3.CONTENT−>>′.indexInfo.code'

4、查询

SELECT t3.*

FROM(SELECT t1.*,

IF (FIND_IN_SET(parent_id, @pids) > 0,@pids := CONCAT(@pids, ',', id),'0') AS ischild

FROM(SELECT t.id,t.parent_id,t.NAME,t.TITLE

FROM da_tag_dim AS t

ORDER BY t.id ASC) t1,

(SELECT @pids := 'zb2023033100113') t2) t3

WHERE ischild != '0';

5、更新json

JSON_SET(t5.content,' . P R I V C O L 0 02 0 ′ , ′ 2022092501 2 ′ ) 多个: a . c o n t e n t = J S O N S E T ( a . c o n t e n t , ′ .PRIV_COL_0020',' 20220925012') 多个:a.content = JSON_SET(a.content,' .PRIVCOL0020′,′20220925012′)多个:a.content=JSONSET(a.content,′.senCode','20211221004',' . u p d a t e C y c l e I d ′ , ′ 2023091800 1 ′ , ′ .updateCycleId','20230918001',' .updateCycleId′,′20230918001′,′.hasDate','08:00','$.maxAccount','1' )

UPDATE da_dataset_table t5 INNER join da_assets_version t4 on t4.DATASET_ID=t5.DATASET_ID INNER join da_assets a on a.ASSETS_VERSION_ID=t4.id SET t5.content = JSON_SET(t5.content,'$.PRIV_COL_0020','

20220925012') WHERE a.id in ('1020005101168750593');

相关推荐
云和数据.ChenGuang1 小时前
Django 应用安装脚本 – 如何将应用添加到 INSTALLED_APPS 设置中 原创
数据库·django·sqlite
woshilys2 小时前
sql server 查询对象的修改时间
运维·数据库·sqlserver
Hacker_LaoYi2 小时前
SQL注入的那些面试题总结
数据库·sql
建投数据3 小时前
建投数据与腾讯云数据库TDSQL完成产品兼容性互认证
数据库·腾讯云
Hacker_LaoYi4 小时前
【渗透技术总结】SQL手工注入总结
数据库·sql
岁月变迁呀4 小时前
Redis梳理
数据库·redis·缓存
独行soc4 小时前
#渗透测试#漏洞挖掘#红蓝攻防#护网#sql注入介绍06-基于子查询的SQL注入(Subquery-Based SQL Injection)
数据库·sql·安全·web安全·漏洞挖掘·hw
你的微笑,乱了夏天4 小时前
linux centos 7 安装 mongodb7
数据库·mongodb
工业甲酰苯胺4 小时前
分布式系统架构:服务容错
数据库·架构
独行soc5 小时前
#渗透测试#漏洞挖掘#红蓝攻防#护网#sql注入介绍08-基于时间延迟的SQL注入(Time-Based SQL Injection)
数据库·sql·安全·渗透测试·漏洞挖掘