Is it possible to UNION queries from tables or views that don’t have any result in common? What I’m trying to do is combine data from different views into one result. I have
select a,b,null,c from VIEW1, VIEW2 where VIEW1.a = VIEW2.a
UNION
select null,null,z,null from VIEW3
I would like the result to be a,b,z,c. Is this where I would use select from? What does that look like?
select ? from (
select a,b,null,c from VIEW1, VIEW2 where VIEW1.a = VIEW2.a
UNION
select null,null,z,null from VIEW3)
I’m using MS SQL Server and the views do not have primary keys. Thanks so much.
If I understand your question, you’re probably getting results like this:
l
.. but what you’re trying to get are results like this:
Do I understand the problem correctly?
If this is correct, you’ll need to have a way to join these subqueries together, so that you can tell SQL that the 1’s go together, and the 2’s go together, and so on.