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 开发者_StackOverflow社区ROOT/Dir3/Dir6 ROOT/Dir5/Dir7
.... (Order does not matter)
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
精彩评论