I am running this query:
Select column_name
from table
where column_name ~ '%[A-Za-z]%'
group by column_name
but I am not getting any results. What am I doing wrong?
Goal: This is a column that includes phone numbers. I am trying to find any values that contain string characters.
I don't understand why ilike does not support regex This is what I found here
The operator ~~ is equivalent to LIKE, and ~~* corresponds to ILIKE. There are also !~~ and !~~* operators that represent NOT LIKE and NOT ILIKE, respectively. All of these operators are PostgreSQL-specific.
Doesn't this mean I can use ilike by using ~~*?
Edit: What I have learned so far
- Don't use like, use tilda.
Where column_name ~ '%[A]%'Where column_name ~ $$[A]$$does work.
Theory: It has something to with the dollar signs or the apostrophe.
Result: It was the % signs.
ILIKEdoesn't support regex - it only supports the wildcards thatLIKEsupports. If you want regex use the~operator. See the manual for details: postgresql.org/docs/current/static/…