Magneto
10/09/2020, 6:00 PMSELECT * from users WHERE username NOT LIKE '_%'; returns nothing, but SELECT * FROM users WHERE username NOT LIKE '_a%'; returns expected results (I get _d and _k and _n usernames, but no _a results). v4.2.0 am I crazy?zwass
_ being a special character in sqlite: https://sqlite.org/lang_expr.html
An underscore ("_") in the LIKE pattern matches any single character in the string.
zwass
'_%' will match any string with at least 1 character.Magneto
10/09/2020, 6:10 PMzwass
osquery> select 'zwass' LIKE '_%', '_zwass' LIKE '_%', 'zwass' LIKE '\_%' ESCAPE '\', '_zwass' LIKE '\_%' ESCAPE '\';
'zwass' LIKE '_%' = 1
'_zwass' LIKE '_%' = 1
'zwass' LIKE '\_%' ESCAPE '\' = 0
'_zwass' LIKE '\_%' ESCAPE '\' = 1Magneto
10/09/2020, 6:13 PMseph
seph
select username from users where instr(username, "_") != 1;Magneto
10/09/2020, 6:22 PMSELECT * FROM users WHERE username NOT LIKE '\_%' ESCAPE '\'; was what I ended up with, gives me most everything I anticipate.seph
zwass
seph