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'
-
Alex Fenech commented
Sorry the formatting didn't keep; it didn't recognize the string of spaces to line it all up.