ORACLE逗号分隔的字符串字段,关联表查询

使用场景如下:

oracle12 以前的写法:

sql 复制代码
select
    t.pro_ids,
    wm_concat(t1.name) pro_names
from info t,product t1
where instr(','||t.pro_ids|| ',',','|| t1.id|| ',') > 0
group by pro_ids

oracle12 以后的写法:

sql 复制代码
select
    t.pro_ids,
    listagg(DISTINCT t1.name,',') pro_names
from info t,product t1
where instr(','||t.pro_ids|| ',',','|| t1.id|| ',') > 0
group by pro_ids

参考原文:https://blog.csdn.net/x1107761900/article/details/88972610

https://blog.csdn.net/AlbenXie/article/details/102698460

相关推荐
黄俊懿6 小时前
MySQL主从复制:从“异步“到“GTID“,数据同步的进化之路
数据库·sql·mysql·oracle·架构·dba·db
看海的四叔7 小时前
【SQL】SQL-管好你的字符串
大数据·数据库·hive·sql·数据分析·字符串
秋97 小时前
TiDB 数据库全链路实战指南:从下载部署到 Java 高并发调优
java·数据库·tidb
zhou周大哥7 小时前
银河麒麟安装mysql
数据库·mysql
无敌的黑星星7 小时前
Spring @Transactional 注解全解析
java·数据库·oracle
Rust研习社8 小时前
Rust + PostgreSQL 极简技术栈应用开发
开发语言·数据库·后端·http·postgresql·rust
河阿里8 小时前
MyBatis-Plus:MyBatis的进阶开发
数据库·mybatis
sjsjsbbsbsn8 小时前
向量数据库
数据库
逸Y 仙X8 小时前
文章十六:ElasticSearch 使用enrich策略实现大宽表
java·大数据·数据库·elasticsearch·搜索引擎·全文检索
Sherry Wangs8 小时前
MySQL 与向量数据库的核心区别:从结构化数据到语义搜索
数据库·mysql