mercredi 5 août 2015

MySql How to get records as per request in the table mentioned


This is am employees record. Say some employees are manager to other employees and recognized by emp_id in manager_id column. For example Manager of Ram and Laxhman is Gopi, Manager of Krishna is Laxhman. Now i want to get records of emp_id, emp_name and his manager name. Below is the table

emp_id  emp_name    manager_id
1       gopi            0
2       Ram             1
3       Laxhman         1
4       krishna         3

Would anybody help me in sorting this query using mysql(in single query).

Many Thanks in advance.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire