List:General Discussion« Previous MessageNext Message »
From:Victor Reus Date:January 13 2004 9:19am
Subject:Re: hierarchical records, I need some help!! ;(
View as plain text  
Hi again,

> Second: specify what you mean with "all relations". Can you
> share some sample data and sample output (that is: what
> do you expect the query to return).

Ok my table noms is like

 | id           | int(11)      |      | PRI | [NULL] | auto_increment
 | reference    | varchar(255) |
 | component    | varchar(255) |

The relation between refefence and component are like parent -> child
Here is an example
Table contains :

ID    REFERENCE  COMPONENT
1     A004       B001
2     B001       C003
3     B001       D003

(I have more records but only this are what i want to take as an example)

So the relations are like a hierarchical tree:

A004
   BOO1
      C003
      D003

And i want one sentence that takes all the relations.

The SQL statement result should be like:

REFERENCE  COMPONENT
AOO4       B001
B001       COO3
B001       COO3
....       ....


Coudl somebody give me a tip to do it?.

Thanks.
Victor.



> Victor,
>
> First: don't ask the same thing twice.
>
>> I have one table called noms like this:
>>
>>
>> | id             | int(11)      |      | PRI | [NULL] | auto_increment
>> | | reference    | varchar(255) |
>> | component    | varchar(255) |
>>
>> the relation between reference and component is  hierarchical like
>> reference - > component
>>               reference -> component
>>
>> I want to have all the items into a recorset with only one query like
>>
>> Select id, reference, component from NOMS where reference = '00004'
>>
>> but i want not only the primary relations, i want all relations.
>
> Second: specify what you mean with "all relations". Can you
> share some sample data and sample output (that is: what
> do you expect the query to return).
>
> With regards,
>
> Martijn Tonies
> Database Workbench - developer tool for InterBase, Firebird, MySQL & MS
> SQL Server.
> Upscene Productions
> http://www.upscene.com
>
>
> --
> MySQL General Mailing List
> For list archives: http://lists.mysql.com/mysql
> To unsubscribe:
> http://lists.mysql.com/mysql?unsub=1


______________________________________
Linux Rulez!!
Registered Linux User: 230557
La vida es modular.


Thread
hierarchical records, I need some help!! ;(Victor Reus12 Jan
  • Re: hierarchical records, I need some help!! ;(Martijn Tonies12 Jan
    • Re: hierarchical records, I need some help!! ;(Victor Reus13 Jan
      • Re: hierarchical records, I need some help!! ;(Steve Folly13 Jan
        • Re: hierarchical records, I need some help!! ;(Jochem van Dieten13 Jan
          • Re: hierarchical records, I need some help!! ;(Steve Folly14 Jan
        • RE: hierarchical records, I need some help!! ;(Matt Griffin13 Jan
  • Re: hierarchical records, I need some help!! ;(Mike13 Jan