4

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

2 Answers 2

6

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/

Sign up to request clarification or add additional context in comments.

Comments

1

Have figured this one out:

I need to use like instead of =

i.e.

select from tab where col2 like "test"

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.