2013-07-26 23 views
4

我建立像這樣的表:選擇 - KDB

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

我現在想選擇其中col2的值爲"testchararr"行。我曾嘗試過這樣的:

select from tab where col2 = "test" 

但這總是返回'length錯誤。

如何根據char數組的值查詢?由於

回答

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

我建議檢查每種方法的速度。有關qsql的更多示例,請參閱: http://www.timestored.com/b/forums/topic/string-functions-like-search-replace-regex/

1

想通這一個:

我需要使用like代替=

select from tab where col2 like "test"