I have three tables, A, B, and C. They all hold different data, but have some columns in common.
If A, B, and C all have columns C1 and C2 then how can I look up a specific C2 value using a C1 value that could be in any of the 3 tables?
Basically, I want to do a simple look-up but have it act on the union of the 3 tables - and I'd prefer to not use a view to achieve this.
Note that this is an Ingres Vectorwise database.
You do this by doing a union of the tables in the
from
clause:I've used
union all
for performance reasons. If you are concerned about duplicate values, either useunion
or add adistinct
in theselect
.This is standard SQL and should work in any database.