MySQL Show records of current user + users that he is a parent of -


How can I go about writing a MySQL code to get the record of the current logged in user and at the top of it, The user that he is a parent?

  user_id | Username Parent_user_id --------- + ------------ + ----------------- 1 | Alvin | Zero 2 Gary 1 3 Tom | 1   

We enter the user Alvin and the basic MySQL statement ... ... (Pseudocode) selects the order related to this Alwin. WHERE user_id = $ _SESSION ['loggedUser']

by order

  SELECT * command I would like to know about writing a statement which orders from Gary and Tom Also displays (Definition defined in relation between parent, user's desk? Or lack of restricted word to look like a team leader / leader of a better leader.  

* Also want to add That order table only stores information and a user name field st To thank the user

Many thanks!

Try it out: SELECT commands from WHERE user_id = $ _SESSION ['loggedUser'] or user_id IN (user select user where parent_user_id = $ _SESSION ['loggedUser'])

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -