0

I am trying to do the following query, where a user has a location_id and that location table is recursive.

Locations
========
id
name
level
parent_id

Users
=====
id
name
location_id

Is there any way I can get all levels of the locations in one query?

Huy Nguyen
  • 2,025
  • 3
  • 25
  • 37
Carlos
  • 1,261
  • 11
  • 27
  • You can, see here: http://stackoverflow.com/a/7324296/18565 – Kris Jul 25 '16 at 08:20
  • Possible duplicate of [What are the Options for Storing Hierarchical Data in a Relational Database?](http://stackoverflow.com/questions/4048151/what-are-the-options-for-storing-hierarchical-data-in-a-relational-database) – Martin Schneider Jul 25 '16 at 08:22
  • You could modify [this](http://stackoverflow.com/a/31967073) answer of mine for your purposes – Drew Jul 25 '16 at 10:25

0 Answers0