RE: [PHP-DB] RE: regarding multiple joins
| From: | Jonathan Narong | Date: | Sat, 23 Nov 2002 02:42:46 +0000 |
| Subject: | RE: [PHP-DB] RE: regarding multiple joins | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-23612@lists.php.net to get a copy of this message | ||
that worked perfectly! thank you so much!
-jon
-----Original Message-----
From: Rick Widmer [mailto:php3@developersdesk.com]
Sent: Friday, November 22, 2002 6:08 PM
To: Jonathan Narong; David Elliott; Jonathan Narong on PHP-DB
Subject: Re: [PHP-DB] RE: regarding multiple joins
At 05:26 PM 11/22/02 -0800, Jonathan Narong wrote:
>sorry for my confusing email... i'll try to clarify what i was asking:
>
>i have two tables (i shortened them to only show the parts relating to what
>i'm trying to do now) ...
>
>CREATE TABLE articles (
> id smallint(4) unsigned zerofill NOT NULL auto_increment,
> title varchar(40) NOT NULL default '',
> public char(1) NOT NULL default 'y',
> author smallint(6) default NULL,
> editor smallint(6) default NULL,
> photog1 smallint(6) default NULL,
> photog2 smallint(6) default NULL,
>
>CREATE TABLE people (
> id tinyint(3) unsigned NOT NULL auto_increment,
> name varchar(30) NOT NULL default '',
Try this...
SELECT title, a.name AS AuthorName, b.name AS EditorName,
c.name AS Photog1Name, d.name AS Photog2Name
FROM articles, people a, people b, people c people d
WHERE author = a.id AND editor = b.id
AND photog1 = c.id AND photog2 = d.id
AND what ever else you want in the where clause;
Rick