Reputation: 573
I've got two tables:
personal
____________
| id | name |
| 15 | Mike |
| 23 | Rich |
| 35 | Hugo |
and
events
___________________________
| id | driver | translator |
| 22 | 15 | 23 |
| 23 | 35 | 35 |
is there a way to join these two tables to get something like
events
___________________________________
| id | driverName | translatorName |
| 22 | Mike | Rich |
| 23 | Hugo | Hugo |
thx
Upvotes: 0
Views: 67
Reputation: 11
This will work
select e.id, (select name from Personal where id = e.driver) as DiverName,
p.name as TranslatorName
from Personal p
inner join [events] e on p.id = e.translator
Upvotes: 1
Reputation: 660
you can try this
SELECT
e.id
,p1.name driverName
,p2.name translatorName
FROM `events` e
JOIN `personal` p1
ON p1.id=e.driver
JOIN `personal` p2
ON p2.id=e.translator
Upvotes: 1