I use the query tool in pgAdmin 4 connected a database. In one of the tables, one of the columns should contain values that are exactly 8 digits (e.g. 12345678).
There are 99 that are exactly 8 digits and 1 that is empty (null).
I would like to create a query that finds the empty one. The following query returns the 99 records that match:
SELECT COUNT (*) FROM my_table WHERE my_column ~ '^[0-9]{8}$';
The problem is that when I add ! (negative, just before the tilde), I get 0 matches rather than 1 as expected:
SELECT COUNT (*) FROM my_table WHERE my_column !~ '^[0-9]{8}$';
Any idea what could go wrong?
WHERE my_column ~ '^([0-9]{8})?$'?