Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

EbrahemSamer's avatar

How to merge two Select queries depending on each other ? PHP Native

Hello,

I've users table

id, email, super (0 => if user is an admin).

user may be an admin and supervise other users ( clients ).

user may be a client and supervise other users ( employees ).

user may be an employee and no one can be under an employee.

I want admin to has the ability to view all his clients and all employees under each client......

Can I make something like that in SQL Queries

PSEUDO CODE

SELECT * FROM users WHERE super = 2 AND ( SELECT * FROM users WHERE super = each id FROM THE FIRST QUERY )

0 likes
1 reply

Please or to participate in this conversation.