根据char数组列的值进行选择 - KDB

ElF*_*Fik 4 kdb

我有一个像这样的表:

tab: ([]col1:();col2:())
`tab insert (`testsym; "testchararr")
Run Code Online (Sandbox Code Playgroud)

我现在想要选择col2具有值的行"testchararr".我试过这样:

select from tab where col2 = "test"
Run Code Online (Sandbox Code Playgroud)

但这总是会返回'length错误.

如何根据char数组的值进行查询?谢谢

Joh*_*red 5

使用"喜欢"或副词.例如

q)select from tab where col2 like "testchararr"
col1    col2
---------------------
testsym "testchararr"

q)select from tab where col2~\:"testchararr"
col1    col2
---------------------
testsym "testchararr"

q)select from tab where col2 like "test"
col1 col2
---------

q)select from tab where col2~\:"test"
col1 col2
---------
Run Code Online (Sandbox Code Playgroud)

我建议检查每种方法的速度.有关qsql的更多示例,请参阅:http://www.timestored.com/b/forums/topic/string-functions-like-search-replace-regex/