I'm searching how to check if any field contains the TAB character.
after read this post, I tried to use this command :
SELECT id FROM account WHERE description LIKE '%\t%';
But it returns me all fields that contain the 't' character.
Do you have any solution to represent the TAB character ?
select * from MyTable where Field1 '%' || CHR(9) || '%'; Other solution can be: Select * from MyTable where instr(Field1, CHR(9)) <> 0; Cheers!
SELECT * FROM spatial_ref_sys WHERE srtext LIKE '%\ /%'; Sometimes these ticks are very useful for searching special characters in a database.
The PostgreSQL LIKE operator is used to match text values against a pattern using wildcards. If the search expression can be matched to the pattern expression, the LIKE operator will return true, which is 1. The percent sign represents zero, one, or multiple numbers or characters.
PostgreSQL LTRIM, RTRIM, and BTRIM functionsThe LTRIM() function removes all characters, spaces by default, from the beginning of a string. The RTRIM() function removes all characters, spaces by default, from the end of a string. The BTRIM function is the combination of the LTRIM() and RTRIM() functions.
you have to use a literal tab chacater,
SELECT id FROM account WHERE description LIKE '% %';
In psql type ctrl-V and then TAB to enter a tab. in other environments there are other ways to enter literal tabs.
Alternatively you can use escape string syntax: e'%\t%'
, or octal escape e'%\011%'
.
In SQL there is no "escaping" of characters like \t
. You can use the chr()
function for this:
select id
from account
where description LIKE '%'||chr(9)||'%'
I prefer the strpos
function in this case, because I think it makes the intention clearer
select id
from account
where strpos(description, chr(9)) > 0
I'm very late to this party, but having looked into this today, I've found you can also use regular expression.
SELECT id FROM account WHERE description ~ '\t';
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With