regarding multiple joins

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



this is a problem i've been struggling with for a little while. any attempt
to find help online has not produced any useful information. this is
regarding joins, which i'm not an expert in, but hopefully one of you can
help me out.

i have an table 'articles' which has multiple fields, such as author,
editor, photographer, etc.. each of these fields contains an index number
which relates to another table 'people' that lists everyone. basically i
just want to select  everything with the names displaying, instead of id
numbers.

the way i'm currently doing this is pretty inefficient; on the display page,
i have multiple queries. first to extract everything from the articles
table, and then a query for each field (i.e. SELECT name FROM authors WHERE
(author_id = $id). This works, although I'm pretty sure there's a much more
efficient way of doing this with one query.

I know a method would be to have separate tables for authors, editors,
photographers, etc... but in this case, it would be simpler to just relate
everything to the one "people" table. THis is because any particular person
could take on multiple tasks, or different ones, for different articles.

Hope this all makes sense. I have a feeling aliases will be need to used,
although I'm not exactly sure how.

Thanks for any help you guys might be able to provide. ;-)

-jon



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux