Is it possible to create a database view that emulates the select query below?
select
A.Name,
B.Subscription
from
TestTableA as A left outer join TestTableB as B on A.ID = B.A_ID and Subscription = 'xxxx';
With a view I can't see how I can filter the Subscription in the join clause and instead can only have it as a condition on the query's where clause.
(A more involved version of this question).
Update:
TestTableA
ID | Name
---|------
1 | Joe
2 | Jane
TestTableB
ID | A_ID | Subscription
---|------|-------------
1 | 1 | abcd
2 | 1 | efgh
Query Results:
Using the above "select" statement the result set is:
Name | Subscription
-----|-------------
Joe | null
Jane | null
What I'm trying to achieve is to create a view that returns me the same thing.
select * from MyView where Subscription is null Subscription = 'xxxx';
Currently all I can achieve with a view and the query immediately above is as below. I have no way to get "Joe" into the results with a null subscription.
Name | Subscription
-----|-------------
Jane | null