Oskar MorgensternGuest
Hi,
How do I compare strings for equality in kdb+?
I have tried the following:
`q)t:([] row:1 2 3 4 5; company:(“Ford”;”Nissan”;”Skoda”;”GM”;”Rover”))
q)t
row company
————
1 “Ford”
2 “Nissan”
3 “Skoda”
4 “GM”
5 “Rover”
q)select from t where company=”Ford”
‘length
=
(“Ford”;”Nissan”;”Skoda”;”GM”;”Rover”)
“Ford”
q)select from t where company~”Ford”
row company
———–
`
Strangely in seems to work as expected but this isn’t an ideal solution.
`
q)select from t where company in (“Ford”;”Ford”)
row company
———–
1 “Ford”`
Why do I get a length error comparing the strings using equals?
Thanks.
Scott FGuest
You can use like to compare strings:
q)select from t where company like “Ford”
row company
———–
1 “Ford”
Regards