cancel
Showing results for 
Search instead for 
Did you mean: 

Column Name same as Variable

harshshekhar
New Contributor
Hi,
I stumbled upon a strange problem where I will need help.


If I have a table with column name same as name of a variable which I am using as a matching condition in my query,I dont get the matching row.
Rather I get all rows available in table

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.

Here name of column is "name" and name of variable used as matching condition is also "name"

Regards,
Harsh

1 REPLY 1

sohagan857
New Contributor
Hi Harsh, You can get around this by multiple methods, here are three: // define table q)d1:`name`age!(`Methuselah`Jared`Noah; 969 962 950) q)t1:flip d1 q)name:`Jared // access the name value by grabbing it from it's dictionary (root) q)select from t1 where name=(`. `name) name age --------- Jared 962 // use lambdas and pass name in as param q){[x] select from t1 where name=x}[name] name age --------- Jared 962 // don't use the columns names q)namep:name q)select from t1 where name=namep name age --------- Jared 962 HTH, Sean