mysql - Go up through hirachical data for specific row in the same table (row = location in opengeodb) -
Let me ask opengeodb to find 'Bundesland' in an open space. You can get information about DB Schema. Sorry, only German documentation is text, but the graphical schema on this page is in English.
To make it possible that the OpenGD is extended, the data is stored exclusively later, which means that any location data has one line and one type but between the places no direct There is no connection. If you are directly related to the place, then you can easily ask other information to any particular place_id. But I need to go through a helpless chain where I do not know how many steps are Nakasari. Example: I have a village with loc_id = 1 and I know that this village is part of loc_id = 2 (loc_id = 2 is the county's say) I know that with the village loc_id = 1 also stores the location which comes under the area 'part_of' which holds another loc_id
but now my problem is - I want to know that this village is moving forward in the series Used to be. In this case I need a state
For example village -> county -> district -> state
whether it is possible with pure SQL or I need to write a script is?
I try to explain it with example data. / P>
loc_id | Type | Name | Part_of ---------------------------------------- 1 | Village | Springfield | 2 2 | County County Name | | 3 3 State | Statmanum | 4 ... I now need a SQL which gives me back all the data for the village (WHEEE Lok_ID = 1) and runs in Hiraki and gives me a static statement in the attic Cloumn's Something like this:
1 | Springfield | Statemen should be the result.
Can it be tested? And it is also not safe to say that there is always a single step in the chain (maybe it is related to a county between a district or village that is connected to a city). Type = 'state', it will be necessary to stop running until it reaches.
Thanks for any thoughts! Marcus
Supports standard SQL recursive queries, but MySQL does not have this feature.
There are several ways to store hierarchical data in Microsoft, even if there is no support for recurring questions. See my presentation for example.
Comments
Post a Comment