如何使用H2数据库中的列Containg数组以获取N 1行
我是H2数据库的新手。我在数据库中有3个表,
:
desc | somending_id | 1 | 1 |
---|---|---|---|
en | 142868 142868 151508 | xyz | 4686,4687] |
表条件条件条件
desc | column3 | 4686 |
---|---|---|
desc1 | dess | 4687 |
desc2 | desc2 desc2 | desc2 something |
2
表 | [ | condition_id | sometsing |
---|---|---|---|
ID | T1 142868 151508 | xyz | desc1 sosings1,desc2 somethin2 |
如何做到这一点,我尝试了array_contains,但是它给出了2行,结果是't1ID t1desc t1something Join join join ofin ofin coin of Cinter 1 en 142868 151508 151508 xyz desc1 xyc1 somets 1 1 en 142868 142868 151508 xyz xyz22222
。先感谢您
I am new to H2 database. I have 3 tables in database for example,
table t1 :
ID | desc | something | condition_id |
---|---|---|---|
1 | EN 142868 151508 | XYZ | [4686, 4687] |
table condition
CONDITION_ID | desc | COLUMN3 |
---|---|---|
4686 | desc1 | something1 |
4687 | desc2 | something2 |
And I need output like this
ID | desc | t1something | joined Column |
---|---|---|---|
1 | EN 142868 151508 | XYZ | desc1 something1, desc2 somethin2 |
How to do this, I tried with array_contains, but its giving 2 rows as a result like' t1ID t1desc t1something joined Column 1 EN 142868 151508 XYZ desc1 something1 1 EN 142868 151508 XYZ desc2 somethin2
Please help. Thank you in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要从表
t1
将行分组,然后从表条件
汇总行:如果要从
t1
将行排除,而无需在条件,使用内部
JOIN
而不是左JOIN
。您可能还需要在组中添加
(odrer by Some_columns)
从listAgg
汇总函数如果需要一些确切的条目:或者,您可以使用subquery:
You need to group rows from table
T1
and aggregate rows from tableCONDITION
:If you want to exclude rows from
T1
without corresponding entries inCONDITION
, use innerJOIN
instead ofLEFT JOIN
.You may also want to add
WITHIN GROUP (ODRER BY some_columns)
clause toLISTAGG
aggregate function if you need some exact order of entries:Alternatively, you can use a subquery: