Hi I am having difficulty writing an SQL query to do what I want:
I have 1 table with 2 columns, 'id' and 'name':
tbl_names:
id name
-- ----
1 Bob
2 Jeff
3 Fred
4 Joe
5 Bill
I then have another table which contains several fields which hold id's
from the above table:
tbl_output:
id person1 person2 person3
-- ------- ------- -------
1 2 3 1
2 5 4 3
I need a query that will return the names for the specified id from
tbl_output.
If I have just one 'person' field in tbl_output I would do it with an
inner join like this:
SELECT name from tbl_names
INNER JOIN tbl_names on tbl_names.id = tbl_output.person
WHERE tbl_output.id = ?
but I can't figure it out when theres multiple fields to be joined from
the same table...e.g I want to specify tbl_output.id = 1, and it give me:
person1 person2 person3
------- ------- -------
Jeff Fred Bob
Any ideas?
Cheers,
Ben.