RE: [PHP] getting from one table listing from another



[snip]
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?
[/snip]

Exactly. If there is a name in table a that has no points in table b you
will see the name from a and a NULL from b. If you only want names that
have points you can use the implicit join that you illustrate.
.



Relevant Pages

  • Re: [PHP] getting from one table listing from another
    ... tedd wrote: ... I know this is kinda crazy but I need it:P ... I have one table that lists name's ... I'd recommend you learn as much as you can about join operations - they can make life a lot easier and more efficient. ...
    (php.general)
  • RE: [PHP] getting from one table listing from another
    ... I know this is kinda crazy but I need it:P ... I have one table that lists name's ... FROM table a LEFT OUTER JOIN table b ...
    (php.general)
  • Re: Kevin Myers and Darwin
    ... And the lists that this ... As you just poinjted out Rummel selected the Mega killers out. ... You obsess about the church. ...
    (soc.culture.irish)
  • Re: Kevin Myers and Darwin
    ... And the lists that this list ... As you just poinjted out Rummel selected the Mega killers out. ... You obsess about the church. ...
    (soc.culture.irish)
  • Re: 3vl 2vl and NULL
    ... >> Uncle Vernon be included or not? ... and writing your own inserts into those lists to renumber ... >> sense to store an empty set for an empty mug. ...
    (comp.databases.theory)