How to query KDB table where one column is a list?

為{幸葍}努か 提交于 2019-12-06 01:38:28
jomahony
select from table where `book2 in'books

This utilises the adverb each-both, read more about it here: http://code.kx.com/q4m3/6_Functions/#672-each-both

Paul Kerrigan

select from table where `book2 in/:books

is valid, using the eachright adverb.

Another useful variation where you want to match any/all of the input books to the books column :

1) This will return the rows which have both book2 and book5 (using all each):

q)select from table where  all each `book2`book5 in/:books
id| books
--| -----------
5 | book2 book5

2) This will return the rows which have either book2 or book4 (using any each)

q)select from table where  any each `book4`book5 in/:books
id| books
--| ------------
4 | ,`book4
5 | `book2`book5
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!