Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KDB+ Case insensitive like query

SELECT * FROM MarketTable WHERE customer LIKE "ABC"

This returns only ABC. I want this to return ABC, aBC, abc, etc.

Is there something close to ILIKE in kDB+?

Even functions like lower or tolowercase would help, but I do not think these are available. As in java we have string.tolowercase.

like image 627
deepak p Avatar asked Apr 30 '26 05:04

deepak p


1 Answers

q)t:([] b:1 2 3; a:("abC";"aBc";"AbC"))
q)t
b a
-------
1 "abC"
2 "aBc"
3 "AbC"

q)select from t where upper[a] like "ABC"
b a
-------
1 "abC"
2 "aBc"
3 "AbC"

q)select from t where lower[a] like "abc"
b a
-------
1 "abC"
2 "aBc"
3 "AbC"

However this way the conversion has to happen on each query. Faster to store the column in the format that it will be queried.

like image 86
Ryan Hamilton Avatar answered May 01 '26 18:05

Ryan Hamilton



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!