Hello,
I stumbled upon a problem where I have a value stored in a variable and then I am trying to run a query to fetch row based on matching value however I dont get intended results.Wondering if you can help?
d1 : name
age!(Methuselah
Jared`Noah; 969 962 950)
t1: flip d1
name:`Jared
select from t1 where t1[`name] = name
It gives all the rows of table instead of one matching row
Hi Harsh,
kdb is trying to evaluatee each name against each name and thus all are true, which is why it returns all results from the table, you could either rename the name:`Jared variable to something else to avoid this, or pass it in as an argument to a function that will perform the select statement.
For example:
q){select from t1 where name=x}[name]
name age
Jared 962
or
q)name2:`Jared
q)select from t1 where name=name2
name age
Jared 962
Phil