Viju Viju - 1 year ago 113
SQL Question

mysql get name by id in select query in multiple records

i've stuck in mysql query. i've a employee table whose fields are id, name, bossid and bossid is parent id of employee.

enter image description here

How i write the query to print the data in this format

id name boss
1 rajesh rajesh
2 vijay rajesh
3 ravi vijay

Answer Source

Just join the table with itself:

Select as id , as Name , as boss from employee t1 join employee t2 on
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download