Cosmic symbol character literals

I need to query a database containing company names. I have a list of about 50 names for which I should get data. But I can’t write a query using the command as spaces in a name that is not recognized. ex

select from sales where name in (`Coca Cola, `Pepsi)

This gives me an error because "Cola" is not recognized. Is there any way to write such a query?

+5
source share
2 answers

The spaces between the lines cause the interpreter to get confused. `$ () Converts a list of characters to characters.

q)t:([] a:1 2 3; name:`$("coca cola";"pepsi";"milk"))

q)select from t where name in `$("coca cola";"pepsi")
a name
-----------
1 coca cola
2 pepsi

You can also be careful with the case and either use lower or upper case sequentially, which will lead to unexpected empty results:

q)select from t where name in `$("Coca Cola";"Pepsi")
a name
------

q)select from t where upper[name] in upper `$("Coca Cola";"Pepsi")
a name
-----------
1 coca cola
2 pepsi
+3
source

- :

select from sales where name in `$("Coca Cola";"Pepsi")
0

All Articles