سؤال

I have a table built like so:

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

I now want to select the row where col2 has the value "testchararr". I have tried like so:

select from tab where col2 = "test"

but this always returns 'length error.

How can I query based on the value of a char array? Thanks

هل كانت مفيدة؟

المحلول

Use "like" or an adverb. e.g.

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

I advise checking the speed of each method. For more examples of qsql like in use see: http://www.timestored.com/b/forums/topic/string-functions-like-search-replace-regex/

نصائح أخرى

Have figured this one out:

I need to use like instead of =

i.e.

select from tab where col2 like "test"
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top