1

I have created the table and stored the hierarchical data in it. The table is exactly as given this answer. There are some queries for retrieval too.

But i want to list all possible paths from the tables. What is the query ?

The output should be -

ROOT
ROOT/Dir2
ROOT/Dir3
ROOT/Dir4
ROOT/Dir5
ROOT/Dir3/Dir6
ROOT/Dir5/Dir7 

.... (Order does not matter)

0

1 Answer 1

0

You want to fake an unlimited depth or height by repeatley adding left joins to your query. This can only work if you know exactly the height of your tree or you set yourself a limit.

SELECT V.uid UID, V.tiergruppe_id, V1.title Tiergruppe, V.nachweisart_id, V2.title Nachweisart, V.verhalten_id, V3.title Verhalten, V.quelle_id, V4.title Quelle, V.toleranz_id, V5.title Toleranz, V.tag_id, V6.title Tag, V.monat_id, V7.title Monat, V.jahr_id, V8.title Jahr, V.stunde_id, V9.title Stunde, V.minute_id, V10.title Minute, V.von_id, V11.title Von, V.bis_id, V12.title Bis, V.tageszeit_id, V13.title Tageszeit, V.spez_anzahl_id, V14.title Spez_Anz, V.gesamtanzahl Gesamtanzahl, V.amt Amt, V.awt Awt, V.gesamta Gesamta, V.gesamti Gesamti, V.anmerkungen Anmerkungen
        FROM tx_chsffoeag_fundmeldung V INNER JOIN tx_chsffoeag_fund V1 ON V.tiergruppe_id = V1.uid INNER JOIN tx_chsffoeag_fund V2 ON V.nachweisart_id = V2.uid INNER JOIN tx_chsffoeag_fund V3 ON V.verhalten_id = V3.uid INNER JOIN tx_chsffoeag_fund V4 ON V.quelle_id = V4.uid INNER JOIN tx_chsffoeag_fund V5 ON V.toleranz_id = V5.uid INNER JOIN tx_chsffoeag_fund V6 ON V.tag_id = V6.uid INNER JOIN tx_chsffoeag_fund V7 ON V.monat_id = V7.uid INNER JOIN tx_chsffoeag_fund V8 ON V.jahr_id = V8.uid INNER JOIN tx_chsffoeag_fund V9 ON V.stunde_id = V9.uid INNER JOIN tx_chsffoeag_fund V10 ON V.minute_id = V10.uid INNER JOIN tx_chsffoeag_fund V11 ON V.von_id = V11.uid INNER JOIN tx_chsffoeag_fund V12 ON V.bis_id = V12.uid INNER JOIN tx_chsffoeag_fund V13 ON V.tageszeit_id = V13.uid INNER JOIN tx_chsffoeag_fund V14 ON V.spez_anzahl_id = V14.uid
        WHERE
            V.deleted=0 AND V.hidden=0 AND V1.deleted=0 AND V1.hidden=0
2
  • if i set a limit can i get the output as above ?
    – JOHN
    Jul 24, 2011 at 4:51
  • Jitamaro : love to know the sql query then.
    – JOHN
    Jul 24, 2011 at 18:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.