quick query help
| From: | Jason Dulberg | Date: | Fri, 10 Aug 2001 20:30:14 +0000 |
| Subject: | quick query help | ||
| Groups: | php.db | ||
| Request: | Send a blank email to php-db+get-11238@lists.php.net to get a copy of this message | ||
I'm running into a little problem with a LEFT JOIN and I was wondering if
someone here could give me some suggestions on how I can get it to work.
Basically, what I'd like to do is when a house is shown, grab agentname from
the agents table.
Here's my simplified db structure:
CREATE TABLE agents (
id int(11) DEFAULT '0' NOT NULL auto_increment,
agentname varchar(40) NOT NULL,
);
CREATE TABLE homes (
id int(11) DEFAULT '0' NOT NULL auto_increment,
owner int(11) DEFAULT '0' NOT NULL,
PRIMARY KEY (id),
KEY owner (owner),
);
And here's what I currently have for my select statement:
SELECT h.* FROM homes h LEFT JOIN agents a ON (h.owner = a.id) WHERE
h.price>=10000000 etc. etc.
(the "where" part of the select statement of course changes depending on the
users form input)
Any suggestions are greatly appreciated!
Thanks.
__________________
Jason Dulberg
Extreme MTB
http://extreme.nas.net