英文:
Select row by array contains check
问题
我有一个类似的表格
CREATE TABLE table(
name VARCHAR(100) NOT NULL,
array INTEGER ARRAY NOT NULL
);
例如,如果我有以下行
name: test, array: [1, 2, 3]
name: test2, array: [663, 332, 334]
如何选择包含 332 在 array 中的行?该数组的长度可以是任意的,但不会为 null。
不幸的是,在 HSQLDB 数组方面没有太多的文档.. 我正在使用版本 2.5.1 和 Java JDBC。
英文:
I have a table like
CREATE TABLE table(
name VARCHAR(100) NOT NULL,
array INTEGER ARRAY NOT NULL
);
For example if I have the rows
name: test, array: [1, 2, 3]
name: test2, array: [663, 332, 334]
How can I select the row which contains 332 in array? The array can be of any length but never null.
Unfortunately there isn't much documentation on HSQLDB arrays.. I'm using version 2.5.1 with Java JDBC.
答案1
得分: 0
已解决。之前的方法调用引发了一个异常,阻止了实际异常的抛出。
SELECT * FROM table WHERE 332 IN ( UNNEST(array) )
英文:
Solved it. There was an exception caused by a previous method call which prevented the actual exception from throwing.
SELECT * FROM table WHERE 332 IN ( UNNEST(array) )
答案2
得分: -1
SELECT 332 IN UNNEST([663, 332, 334]) AS contains_value;
英文:
SELECT 332 IN UNNEST([663, 332, 334]) AS contains_value;
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论