【问题标题】:select based on value of char array column - KDB根据 char 数组列的值进行选择 - KDB
【发布时间】:2013-07-26 10:17:39
【问题描述】:

我有一个这样构建的表:

tab: ([]col1:();col2:())
`tab insert (`testsym; "testchararr")

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

select from tab where col2 = "test"

但这总是返回'length 错误。

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

【问题讨论】:

    标签: kdb


    【解决方案1】:

    使用“喜欢”或副词。例如

    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
    ---------
    

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

    【讨论】:

      【解决方案2】:

      已经解决了这个问题:

      我需要使用like 而不是=

      select from tab where col2 like "test"
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-07-26
        • 2018-01-20
        • 1970-01-01
        • 2015-06-04
        • 1970-01-01
        • 2023-02-03
        • 1970-01-01
        相关资源
        最近更新 更多