Sorry, I could be a little thicker here. Are you trying to return rows that received SOMETHING in one of the columns (except for the id column)?
You cannot do
create vw_View_Fields1to5 as
select id from employees
where name is not null or description is not null or field3 is not null
or field4 is not null or field5 is not null;
create vw_View_Fields6to10 as
select id from employees
where field6 is not null or field7 is not null or field8 is not null
or field 9 is not null or field10 is not null;
(etc)
select id from vw_View_Fields1to5
union
select id from vw_View_Fields6to10 .... (etc)
You need to take DISTINCT or something to cut lines that fall into more than one view, of course.
If you want rows that have NOTHING in any column other than id to switch ' or blah is not null ' to be , and blah is null '(etc.).
Does that make sense ... or am I missing something ?:-)
EDIT: Actually, I think the UNION process will result in different lines appearing anyway (unlike UNION ALL), but I could be wrong - I haven't really tried this ... (yet!)
source share