zjc
zjc

Reputation: 11

kdb/q, reserved word as column name

I have a kdb table with column name type and want to select data by a giving type. It's like:

select from table where type=giving_type

it issues an error of : 'type, because type is a reserved word in q.

Then how to do this?

Upvotes: 1

Views: 1946

Answers (2)

clony
clony

Reputation: 136

Generally you should avoid using kdb reserved words such as "type" as the column name.

In this particular case where the table does have "type" as column name, functional select is the solution.

You can find the functional form of a select query via the parse function:

parse "select from table where type=giving_type"

Upvotes: 0

hellomichibye
hellomichibye

Reputation: 4302

you could use a functional select:

?[`table;enlist (=;enlist `giving_type;`type);0b;()]

Upvotes: 2

Related Questions