0

I have a table with all of our users (nearly 2000 users):

 username         manager         isvip
 bob              alice           false
 alice            henry           false
 bart             henry           true
 henry                            true

For Bob, I have to find Henry (because bob < alice < henry = vip).

I tried to do some loops to find the manager until the manager is a vip, but it is not optimized at all, and it is very long for 2000 users.

Can I find in an easy way in SQL + PHP the vip for a user?

Grant Miller
  • 27,532
  • 16
  • 147
  • 165
  • 2
    Welcome, please, visit [tour](https://stackoverflow.com/tour) and read [how to ask a question](https://stackoverflow.com/help/how-to-ask). Provide some code you wrote. – PeS Sep 20 '18 at 14:21
  • 1
    show your code which you tried – devpro Sep 20 '18 at 14:21
  • 1
    Show what you tried and show tables structures with some example data and the desired output – executable Sep 20 '18 at 14:23

0 Answers0