db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John English <john.fore...@gmail.com>
Subject Re: Selecting empty columns?
Date Wed, 23 Jan 2013 12:57:03 GMT
On 23/01/2013 14:02, John English wrote:
> I want to select all rows from a table where a varchar column is a zero-length
> string. Of course this works:
>    SELECT * FROM my_table WHERE my_col='';
> but I would have expected this to work too:
>    SELECT *  FROM my_table WHERE my_col NOT LIKE '%_%';
> The first query returns all the expected rows; the second returns zero rows.

Oops, posted too hastily. The actual query used CHAR(my_col), since I don't know 
in advance the type of the column I'm filtering on, and this returns a string 
space-padded to 16 characters from an empty string. Adding TRIM() to this fixed 
the problem.

Apologies for wasting your bandwidth...
John English

View raw message