sql - SQL 中的逗号分隔(带大括号)搜索
问题描述
我有一个这样的 SQL 表:
表格1:
| SomeID1 | OtherID1 | Data1
+----------------+-------------+-------------------
| abcdef-..... | cdef123-... | {18,20,22}
| abcdef-..... | 4554a24-... | {17,19}
| 987654-..... | 12324a2-... | {13,19,20}
还有一张桌子:
表 2:
| SomeID2 | OtherID2 | Data2
+----------------+-------------+-------------------
| abcdef-..... | cdef123-... | 13
| abcdef-..... | 4554a24-... | 14
| 987654-..... | 12324a2-... | 15
| abcdef-..... | 4554a24-... | 16
| 987654-..... | 12324a2-... | 17
是否可以从 table1 收集一个 Data1 值并在 table2 中搜索,例如:
select * from table2 where Data2 in ('18','20','22')
我正在寻找这样的东西:
select * from table2 where Data2 in (select Data1 from table1 where SomeID1='abcdef')
PD:我没有做桌子
解决方案
SELECT SomeID1, OtherID1, Data1 FROM Table1,Table2 WHERE SomeID1 = SomeID2 AND ....
您需要一份独一无二的参考资料
推荐阅读
- java - org.springframework.web.bind.MethodArgumentNotValidException
- valgrind - valgrind 在 mac 和 linux 服务器上的行为不同
- android - 在同一 firebase 数据库的另一个子项的值事件侦听器中使用值事件侦听器查找子值
- amazon-web-services - 我需要订阅哪些主题才能获得 AWS IoT 的下一份工作?
- maven - fabric8-maven-plugin 为 initcontainers 生成 livenessProbe 和 readinessProbe 并且部署失败
- curl - 编译程序时出现卷曲错误
- debugging - 如何在 ucrtbase.dll 中找到在指定偏移处执行的代码?
- python - IronPython cdll 无法加载库。如果不使用 IronPython 也可以工作
- sql - SELECT 语句为 Sybase 表中的每一行返回一个计数
- c# - Dynamic Gridview - 获取第一个子原生广告