【发布时间】:2022-01-23 19:45:19
【问题描述】:
在这两个表中
Table A [id, items]
[1, "a,b,c"]
Table B [id , contents]
["a", apple]
["b", banana]
我想像查询一样立即得到 [apple,banana] 的结果
select contents from B where B.id in ("a","b","c")
或喜欢
select contents from B where B.id in (select A.items from A where id = 1)
【问题讨论】:
-
规范化你的架构。见"Is storing a delimited list in a database column really that bad?"(剧透:是的。)。