SQL query question

Charles Yeomans yeomans at desuetude.com
Thu Feb 12 18:30:13 CST 2004


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

> on 2/13/04 1:01 AM, Charles Yeomans at yeomans at desuetude.com wrote:
>
>> On Feb 12, 2004, at 5:39 PM, Ruslan Zasukhin wrote:
>>
>>> on 2/13/04 12:36 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].
>
> Aha.
>
> You do
>
>     WHERE M1.leftIndex BETWEEN M2.leftIndex AND M2.rightIndex
>
> In any case you must at first make JOIN on 2 tables,
> Before use fields from both.
>
> And yes, I afraid such query will not work.

Is this something that will work in v2?  I gather that it is legal and 
works with other SQL databases.

>
>
>> 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.
>
> Interesting.
>
> I have never it seems hear about such kind if relation :-)
>

It's a very clever idea.  Here are a couple of URLs.

<http://www.sitepoint.com/print/1105>
<http://www.geocrawler.com/archives/3/6/2001/10/0/6961775/>

Charles Yeomans



More information about the Valentina mailing list