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

Reply via email to