如何查询其中一列是列表的KDB表? [英] How to query KDB table where one column is a list?

查看:85
本文介绍了如何查询其中一列是列表的KDB表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在KDB中有一个表,其中的一列是符号列表,例如:-

I have a table in KDB where one of the columns is a list of symbols, for example:-

q)table:([id:1 2 3 4 5] books:((`book1`book2);(enlist `book6);(enlist`book3);(enlist`book4);(`book2;`book5)))
q)table
id| books
--| ------------
1 | `book1`book2
2 | ,`book6
3 | ,`book3
4 | ,`book4
5 | `book2`book5
q)

我想在books列中找到所有bookbook是其中一本书的行,我该怎么做?因此,在上面的示例中,我希望返回第一行和第五行.我已经尝试过使用"in"运算符进行各种操作,但是得到了错误或没有结果,例如:-

I want to find all the rows where `book2 is one of the books in the books column, how do I do this? So in the example above, I'd expect the 1st and 5th rows to be returned. I have tried various things using the "in" operator but either get an error or no results, for example :-

q)select from books where `book2 in books
clientTradeId| book
-------------| ----
q)select from books where enlist `books2 in books
'length

推荐答案

select from table where `book2 in'books

这两个词都使用了副词,请在此处阅读有关它的更多信息: http://code.kx.com/q4m3/6_Functions/#672-两者

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

这篇关于如何查询其中一列是列表的KDB表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆