Advertisement

05.17.2008 at 06:03PM PDT, ID: 23411306
[x]
Attachment Details

To Join or Not To Join

Asked by Hube02 in MySQL

Tags: MySQL, Joins

I have a question for you MySQL Experts.

Say that I have the following tables, with the following columns:
Please note that the names of some of the columns are due to my obsessive need to always know what columns relate to other tables, but this has nothing to do with the question.

Manufacturers:
    manufacturer_id
    manufacturer_name
        -- other manufacturer data columns

ProductTypes:
    producttype_id
    producttype_name
        -- other product type data columns

Categories:
    category_id
    category_name
        -- other category data columns

Images:
    image_id
    image_uri
        -- other image data columns

Products:
    product_id
    Maufacturers_manufacturer_id
    ProductTypes_producttype_id
    Categories_category_id
    Images_image_id
    product_name
        -- other product data columns

Lets say that I create the following query:

Select * From Products, Manufactures, ProductTypes, Categories, Images
    Where Products.Manufacturers_manufacturer_id = Manufacturers.manufacturer_id
    AND Products.ProductTypes_product_type_id = ProductTypes.producttype_id
    AND Products.Categories_category_id = Categories.category_id
    AND Products.Images_image_id = Images.image_id
    ;

I know the above works and returns exactly what I expect it to return. To me this also seems quite straight forward and easy to understand, I can see exactly how things are related.

On the other hand, I'm not too clear on all the Join types and what they actually do.

Here is my question. Is there some advantage to using Joins rather than using syntax as in my example? Do joins make the query faster? or Slower? Is there some other advantage that I'm missing out on?

It seems to me that there is actually less coding in the above than to use Joins as you still need to indicate what columns are related to what columns, plus add the correct Join syntax.

Please enlighten me...Start Free Trial
[+][-]05.17.2008 at 06:23PM PDT, ID: 21591267

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.17.2008 at 06:31PM PDT, ID: 21591277

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.18.2008 at 06:03AM PDT, ID: 21592550

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.18.2008 at 07:53AM PDT, ID: 21592878

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]05.18.2008 at 02:40PM PDT, ID: 21594154

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: MySQL
Tags: MySQL, Joins
Sign Up Now!
Solution Provided By: routinet
Participating Experts: 2
Solution Grade: A
 
 
[+][-]05.18.2008 at 05:26PM PDT, ID: 21594614

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628