Apply SQL 'AND' clause when creating a view
This would be helpful for restricting tables before doing the join when creating a view. A possible workaround would be giving the option to link a view with a view. This is very valuable for historical type tables.
For example:
I have 2 tables, I need to filter table 1 before joining with table 2.
Customer table:
Customer | State
A | S
B | V
C | L
Entry table
Customer | Entry | Category
A | 123 | D
A | 325 | C
A | 496 | D
A | 3874 | M
B | 3478 | A
B | 3234 | D
C | 362 | A
C | 9784 | M
Desired Results:
Customer | State | Entry
A | S | 123
A | S | 496
B | V | 3234
C | L | NULL
SQL would be:
SELECT c.Customer, c.State, e.Entry
FROM Customer c
LEFT JOIN Entry e
ON c.Customer=e.Customer
AND e.Category='D'
![](https://secure.gravatar.com/avatar/4d09ba9ef2fa1c428fcb0a0a17861262?size=40&default=https%3A%2F%2Fassets.uvcdn.com%2Fpkg%2Fadmin%2Ficons%2Fuser_70-6bcf9e08938533adb9bac95c3e487cb2a6d4a32f890ca6fdc82e3072e0ea0368.png)
-
Alex Fenech commented
Sorry the formatting didn't keep; it didn't recognize the string of spaces to line it all up.