SQL query question

Charles Yeomans yeomans at desuetude.com
Thu Feb 12 18:34:02 CST 2004


On Feb 12, 2004, at 6:22 PM, Ruslan Zasukhin wrote:

> on 2/13/04 1:01 AM, Charles Yeomans at yeomans at desuetude.com wrote:
>
>>>> The following query results in error 612.
>>>> SELECT M1.matter_name FROM Matters M1, Matters M2 WHERE M1.leftIndex
>>>> BETWEEN M2.leftIndex AND M2.rightIndex AND M2.matter_name='ICI'
>>>>
>>>> Is such a query not possible in the current version of Valentina?
>>>
>>> But where is your link condition Charles?
>>>
>>> It seems you have self-recursion yes?
>>> With ObjectPtr this works
>>>
>>
>> I am trying something different.  There is another model for
>> representing hierarchical data in a table, based on nested sets.  The
>> idea is this.  A "set" is an interval [a, b].  To each record I
>> associate such a set.  Then I say that record X is a child of record Y
>> if the interval associated to record X is contained in the interval
>> associated to record Y; this clearly defines a partial ordering on the
>> records.  I store the set associated to each record in ULong fields
>> leftIndex and rightIndex.
>>
>> With this scheme, the above query should return the record whose
>> matter_name is 'ICI', plus all of its descendants.
>
> IF you search childs of just ONE record,
> Then I think you can ask only ONE table on BETWEEN
>

Indeed I can.  But what I really want is to do aggregate reports and 
that does seem to require SQL of the sort I gave.  Of course I can 
build my reports using SQL plus some Rb programming.

Charles Yeomans



More information about the Valentina mailing list