Jump to content

Recommended Posts

i don't know if this is a very good topic title, but finding a title is almost more complicated than the problem itself... ;-)

i've got 2 tables: 'device_relation' and 'device'. device relation connects one device to another device.

so in device_relation i've got 3 fields: device_relation_id, output_device_id and input_device_id.

for example: 1, 1, 2. the out_device_id and input_device_id are foreign keys to the 'device' table.

device has got 2 fields: device_id and name.

for example: 1, DVD and 2, TV. so, according to my device_relation table, a DVD is connected to a TV. so far, so good.

however, i can't find a proper query to show both DVD and TV instead of the output_device_id and input_device_id when i select all records from 'device_relation'. i have been busy with joins, but i can't join the device table twice.

does anybody have an idea? thanks in advance!
Link to comment
https://forums.phpfreaks.com/topic/6001-how-to-join-the-same-table-twice/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.