SQL syntax - using the same table twice in FROM statement
Posted in 2004
Twisted data structures - I'm not even sure how to
ask this question.
Conditions:
INFORMIX-OnLine Version 7.23.UC11
INFORMIX-SQL Version 7.20.UD1
I can join between two tables just fine.
I can do a simulated join between a table and itself just fine. I don't
want to, though. Is there an easier way?
Example syntax I'm using now:
select a.f1, a.f2, b.f5, b.f6
from table1 a, table1 b
where a.f1 = "X"
and a.f1 = b.f5
The goal here is to get a dataset out of the table, then go back and get
related data that really should be in a separate table, but is kept in the
same table using the same fields. NOTE: In the actual data structure, there
are several types of data images kept here, and only the fields needed for a
particular type image are used leaving lots of blank space in the record.
I can't split the data appropriately into multiple tables (customer need). I
don't want to build two different views of the same table (excessive
overhead?). I would LIKE to have a more efficient way since I'll go into
production mode with tables in the 20-40 million range rather than the <10K
range.
Any ideas?
Thanks....
Rob