On Tue, Sep 1, 2009 at 8:58 AM, tedd <[email protected]> wrote:
>
> I need to understand joins much better than I do now because the first query 
> I fully understand while the second I don't.
>

Think of the WHERE clause as the filter.  Use it to place restrictions
on what information is returned.

WHERE price > 50 AND color = 'red'

In the previous example you also had things like "vendor.id =
product.vendor_id."  You aren't using this to filter the data.  You
are using it to link up two tables.  This is where the JOIN clause
comes in.  For example, if you want a list of products with their
associated vendors:

FROM products
INNER JOIN vendors ON products.vendor_id = vendors.id -- or whatever
the fields are called

To also link to an optional promotion running for a product:

LEFT OUTER JOIN promotions ON products. promotion_id = promotions.id
_______________________________________________
New York PHP User Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk

http://www.nyphp.org/show_participation.php

Reply via email to