I am trying to query a table on an Oracle Database. It has 4 columns:
- ID (Number)
- EMAIL (Varchar)
- PHONE (Varchar)
- FAX (Varchar).
The ID is a unique identifier and is required. The 3 remaining columns can either have a value, can be NULL or can be an empty string. So, something like:
| ID | EMAIL | PHONE | FAX |
| -- | ----------- | ------------ | -------------- |
| 10 | na@na.ca |888-888-8888 | NULL |
| 11 | |NULL | |
| 12 | buiness@biz.ca | | 666-666-6666 |
| 13 | |NULL | 555-555-5555 |
| 14 |NULL | | NULL |
| 15 |NULL |222-222-2222 | NULL |
I am trying to build a query that only eliminates rows that have no actual value across EMAIL, PHONE or FAX (i.e. a row that does not contain either an email address, a phone number or a fax number). Examples in the table above are row with ID's 11 and 14. So, if there is at least one of or all of an email, phone or fax, I want to include those rows in my query.
I have played around with a couple queries, but I cannot seem to seem to get the results I want. I had thought this was going to be easy, but maybe it's just late in the day. The latest incarnation of my query is something along the lines of:
SELECT c.id, c.email, c.fax, c.phone
FROM
table c
where
(c.email is not NULL or c.email <> '') or
(c.fax is not NULL or c.fax <> '') or
(c.phone is not NULL or c.phone <> '')
The above query only seems to result in rows that have all 3 values. I've tinkered the query a bit with some 'where not' clauses and a mixture of 'or's' and 'and's', however I am not getting what I want. Anything to help would be appreciated.