0

I want to query a table and get all rows where the column i_vhcl_recal is not empty. I ran the following below and kept getting rows that appeared to be empty. Upon inspection, that the fields weren't null but instead they were a string of blank spaces.

How to I query rows where i_vhcl_recal has an actual value and not blank spaces or nulls?

SELECT * 
FROM table 
WHERE i_vhcl_recal IS NOT NULL
GMB
  • 216,147
  • 25
  • 84
  • 135
rsajdak
  • 93
  • 12

2 Answers2

3

Try this:

SELECT * 
FROM table 
WHERE (i_vhcl_recal <> '') IS NOT TRUE;
Óscar López
  • 232,561
  • 37
  • 312
  • 386
0

You could do this with a regex:

select * from table where i_vhcl_recal is not null and i_vhcl_recal !~ '^\s*$';

The interesting thing about '\s' is that it matches on a variety of space characters such as: carriage return, line feed, horizontal tab, vertical tab, form feed.

GMB
  • 216,147
  • 25
  • 84
  • 135