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
Try this:
SELECT *
FROM table
WHERE (i_vhcl_recal <> '') IS NOT TRUE;
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.