SQL WHERE LIKE with tab
10,324
Solution 1
try
CAST(X'09' AS TEXT)
for the tab character
Solution 2
I'm using DB2, but maybe this solution is something you can use on Sqlite also.
Try using the chr function. I think in ASCII the tab character has value 8. In DB2 the following works
SELECT * FROM table WHERE field LIKE '%' || chr(8) || '%'
Related videos on Youtube
Author by
Mark
Updated on August 16, 2022Comments
-
Mark about 1 year
Seems like such a simple thing. I need to specify a WHERE criteria with the LIKE operator and include a tab in the expression.
SELECT * FROM table WHERE field LIKE '%Run1[TAB]%';
I've tried \t, \\t, %t and the char operator.
I am working in Sqlite.
Thanks.
-
boes about 12 yearsMy ascii has become a bit rustii
-
Mark about 12 yearsSo such luck - "Query Error: no such function: chr Unable to execute statement", I do not think sqlite has a char like function
-
Mark about 12 yearsThanks @hatchet, query: SELECT * FROM table WHERE field like '%Run1' || X'09' || '%' does the trick!
-
hatchet - done with SOverflow about 12 yearsglad that worked. I knew X'09' was the key, but wasn't sure whether it needed to be cast or not.