Let’s assume I have a table called normalize with an enum column called type
Depending on the row (Let’s assume the types are a, b or c) I want to do a LEFT JOIN based on whatever the type is.
So, if type = a, LEFT JOIN ON table a .. if type = B, LEFT JOIN ON table b… etc
Can this be done efficiently? Or should this be done at the application layer?
Yes, you should be able to do something like this:
You may or may not need an index on
type, depending on the actual data and how smart your DBMS is (in exploiting indexes that ought to exist underneath PKs). In any case, measure on realistic amounts of data.