I don't have a lot of experience with Oracle, so forgive me if this is obvious:
We have an Employee table with a field named EMPLOYEE_ADDRESS defined as char(60 BYTE)
We want a simple where to find out anyone without anything in their email address field.
The following two queries return no results:
Select * from employee where email_address is null; -- fails because the records aren't null, they're empty;
select * from employee where email_address = '';
So I thought, maybe the issue is that, because of the field definition, I need 60 blank spaces, so I tried this and it returned the expected results:
select * from employee where email_address = ' ';
That works, but it seems dumb and I don't want to put that into production code. So I went on to try to trim the results something like one of the following three queries:
select * from employee where TRIM(email_address) = '';
select * from employee where RTRIM(email_address) = '';
select * from employee where LTRIM(email_address) = '';
None of those worked, so feeling frustrated and just having to know if it would work, I tired this to see if trimming had any effect at all:
select * from employee where ltrim(email_address) || 'a' = 'a';
That worked. (Reaction.. wat?)
So I'm wondering first of all, why using the various trim functions didn't work, and secondly, how can I construct the query so that it's not literally looking for 60 blank spaces?