Sathish
Sathish

Reputation: 4713

detect if a column contains special characters in postgresql table

I have a table in PostgreSQL and I need to detect if a column contains special characters like #,$,^,&,*,@,! etc. or is empty.

For example the table might be like this

enter image description here

How to write a query like this?

Upvotes: 9

Views: 31699

Answers (1)

Sathish
Sathish

Reputation: 4713

Finally i got the solution

select * from table where column1 ~* '[^a-z0-9]' or column2  ~* '[^a-z0-9]' or column3  ~* '[^a-z0-9]'

Upvotes: 27

Related Questions