Re: getting from one table listing from another

From: Date: Sun, 19 Aug 2007 17:11:52 +0000
Subject: Re: getting from one table listing from another
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-261017@lists.php.net to get a copy of this message
tedd wrote:
At 6:12 PM -0500 8/18/07, Jay Blanchard wrote:
[snip] I know this is kinda crazy but I need it :P I have one table that lists name's and I have another table that has the name's and points I want to know how to list the name's of the first table by the points of the second table [/snip] Not crazy, pretty standard from a database point of view; SELECT a.name, b.points FROM table a LEFT OUTER JOIN table b ON(a.name = b.name) This only works if the name in table a matches a name in table b.
Then why use a JOIN? It's my understanding that JOINs are used to included unmatched rows -- am I wrong? Wouldn't this be simpler? SELECT a.name, b.points FROM table_name a, table_name_points b WHERE a.name = b.name Besides, all that JOIN stuff makes my head hurt.
Maybe so, but what you've done there is an implicit join. I'd recommend you learn as much as you can about join operations - they can make life a lot easier and more efficient. -Stut -- http://stut.net/

« previous php.general (#261017) next »