Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL WHERE LIKE with tab

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.

like image 653
Mark Avatar asked Sep 01 '11 16:09

Mark


2 Answers

try

CAST(X'09' AS TEXT)

for the tab character

like image 120
hatchet - done with SOverflow Avatar answered Oct 14 '22 07:10

hatchet - done with SOverflow


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) || '%'
like image 23
boes Avatar answered Oct 14 '22 09:10

boes