Search code examples
where-clausekdbq-lang

select from with wildcard, in Q KDB


I use KDB with a tool that let me set queries. With this tool, only the parameters (filter value) can be changed with user interaction, not the structure of the query. I need a query to be run on user action. By default, I want it to select every rows, and after he select something, I want the query to be filtered by his selection.

For example: By default: select from quote where symbol = *

After the user chooses a symbol: select from quote where symbol = `AAPL

However, the default example doesn't work, because there is no * wildcard in KDB, unlike SQL. How can I get all rows by default then?


Solution

  • Not sure exactly what you're trying to achieve here or what your exact constraints are.

    If you're saying that the equals (=) is fixed then you're restricted to selecting one symbol only....yet you want to return all rows? Technically this can be done in a select statement like so

    select from table where symbol=symbol
    

    but this may not work if your "tool" is expecting an input of type symbol.

    To use a wildcard you'd need "like" instead of equals but it sounds like you can't control that.

    Have you considered that this tool is designed to only allow one symbol filter for a reason ? Perhaps returning all rows would be too much data, perhaps it would be too slow, perhaps it would take too much memory. Feels like you're trying to hack a shortcut