Subject | Re: [ib-support] Join Table with self |
---|---|
Author | Jason Chapman (JAC2) |
Post date | 2002-06-12T10:48:04Z |
> Is it possible to join a table with itself as follows:-If for each TransRef there are 2 rows, you will end up with 4 ( I think)
>
> SELECT * FROM GenLedger a
> JOIN GenLedger b ON a.TransRef = b.TransRef
> AND a.Actn='C'
>
> I run out of memory when I run this query.
rows (If you had no other criteria. The growth is exponencial. I am
assuming that TransRef is not the PK, but a grouping mechanism for entries
in a double entry ledger. I can't see whay you would want to do this, is it
to get all entries that are involved in a transaction that refers to Actn =
'C'?
I would probably do this as
Select * from GenLedger where Tranref in (select Tranref from GenLedger when
Actn = 'C') Especially if Actn does not have an index on it.
What do the two different Q's return as a plan?
JAC