Given the database .....
ID Name item_order Manager
1 ted 2 N
2 bob 5 N
3 tony 1 Y
4 fred 3 N
5 william 4 N
6 george 6 Y
7 cade 8 N
8 matt 7 N
I would like to be able to select Id managers prior to the current name of non-managers. So, for example, the result for bob would be Tony or 3.
I can figure out how to do this with two queries
SELECT MAX( item_order) AS parent
FROM tablename WHERE item_order < 5 && Manager = 'Y'
As a result, I will make another item_order element. Is there a way to do this in just one choice?
maxum source
share