-1
ich verwende PostgreSQL gibt es zwei Tabellen: Schichten und BilderPostgres SQL rekursive Abfragen
LAYERS (layer_id varchar PRIMARY KEY,
parent_id varchar REFERENCES LAYERS(layer_id))
IMAGES (image_id varchar UNIQUE, REFERENCES LAYERS(layer_id))
in LAYERS table: 1->2->3->4->5->6 (1 is the parent of 2)
in IMAGES table: 1,2,5,6
Jetzt weiß ich will, das Bild ist das nächste übergeordnete Bild von Bild 5?
Die Antwort ist Bild 2
Wie schreibe ich solche SQL-Abfrage?
Vielen Dank!
Siehe [Postgres Tutorial] (https://www.postgresql.org/docs/current/static/queries-with.html) und [hier] (https://stackoverflow.com/questions/ getaggte/postgresql + rekursive-Abfrage) –