mysql - Join table more than one id from the joined table -


i have tables this

employee

id  | employee | 1   | gorg     | 2   | ocle     | 3   | oke      | 

task

id  | employeeid1 | employeeid2 1   |  1          |    1 2   |  3          |    2 

query

select a.employeeid1,         b.employee employee1,         a.employeeid2,         c.employee employee2,  `task`  left outer join employee b on a.employeeid1 = b.id  left outer join employee c on a.employeeid2 = c.id 

result

id  | employeeid1 | employee1  |  employeeid2 | employee2 1   |  1          |    gorg    |    1         |   gorg 2   |  3          |    oke     |    2         |   ocle 

in query, have join employee table task employee's name. in the first join, joined employee table employee name employeeid1, in next column of task, there id employee, joined employee again employee's name in employeeid2.

is there better ways prevent join same table first joined table ?


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -