Re: [personal kdb+] how to use like in KDB

Is this what you are searching for ?

{[x;y]select from x where customerName like (“*”,y,“*”)} [( customerName:`abc`bcd`cde )] “bc”

Kim

Am 08.08.2012 16:27, schrieb beginer:

Hi Everyone,

I am writing a function which has two arguments, the first one is a table and the second one is a symbol. It will return a table that filtering out the table with customerName contain ‘name’ which is the second argument. Apparently, it is not working as it seems that kdb doesnt change the name as the argument value. Am I missing something here or its simply not workable 

testfunction: {[table;name]

select from table where customerName like “*name*”

}

Thanks,

J

You received this message because you are subscribed to the Google Groups “Kdb+ Personal Developers” group.
To view this discussion on the web visit https://groups.google.com/d/msg/personal-kdbplus/-/tk6SSD8e5lQJ.
To post to this group, send email to personal-kdbplus@googlegroups.com.
To unsubscribe from this group, send email to personal-kdbplus+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/personal-kdbplus?hl=en.

q)s:([s:()]name:();status:();city:())
q)s insert(s1;smith;20;london)
,0
q)s insert(s2;harry;20;usa)
,1
q)s insert(s3;cyira;20;usa)
,2
q)show s

s name? status city
s1 smith 20??? london
s2 harry 20??? usa
s3 cyira 20??? usa
q)testfunc:{[s;ha] select from s where name like “*ha*” }
q)testfunc[s;`ha]
s name? status city
-----------------
s2 harry 20??? usa
q)

I think you forgot ` when calling the function

Thanks

Hari Om

On Wed, Aug 8, 2012 at 7:57 PM, beginer wrote:> testfunction: {[table;name]>> select from table where customerName like "name"I think the problem is when name (the parameter) is being used as theargument (when you use “name”)try:select from table where customerName like ““,string[name],”