Solved

Triple Inner Join Query Freezes

Posted on 2004-09-26
3
3,363 Views
Last Modified: 2012-05-05
HI. This query runs great in MS-Access but freezes in MySQL:

SELECT DISTINCT Attributes.sku, Attributes.Attribute_Type_Name, Attributes.Enum_Value, Pricing.OurPrice
FROM ((Attributes INNER JOIN SectionProductMap ON Attributes.sku = SectionProductMap.sku) INNER JOIN ConsumerProductData ON SectionProductMap.sku = ConsumerProductData.sku) INNER JOIN Pricing ON Attributes.sku = Pricing.PartNumber
WHERE (((ConsumerProductData.product_type)='Sub') AND ((ConsumerProductData.master_sku)='24-QC12PEP'))
ORDER BY Attributes.sku, Attributes.Attribute_Type_Name;
0
Comment
Question by:ejoan
3 Comments
 
LVL 3

Expert Comment

by:HMax
ID: 12160256
Does it freeze or does it take a very long time to run ?

Have you checked what the mySQL thread are doing, using mySQL Administrator for instance ?
Using this tool, you can see if there are ongoing requests and what are their states, like "copying temporary datas", or "sending datas", etc...

Are all the fields you are making a join on indexed ?

Cheers
0
 
LVL 15

Accepted Solution

by:
JakobA earned 500 total points
ID: 12167355
not a solution, just a rewrit of your query:

SELECT DISTINCT Attributes.sku, Attributes.Attribute_Type_Name, Attributes.Enum_Value,
       Pricing.OurPrice
FROM  Attributes
          JOIN SectionProductMap      ON Attributes.sku = SectionProductMap.sku
          JOIN ConsumerProductData ON Attributes.sku = ConsumerProductData.sku
          JOIN Pricing                       ON Attributes.sku = Pricing.PartNumber
WHERE ConsumerProductData.product_type = 'Sub'
    AND ConsumerProductData.master_sku   ='24-QC12PEP'
ORDER BY Attributes.sku, Attributes.Attribute_Type_Name;

when sending commands to MySQL from php the terminating ';' should be omitted

if you have migrated to a unix/linux based server consider case sensitivity in the table names: http://dev.mysql.com/doc/mysql/en/Name_case_sensitivity.html 
0
 

Author Comment

by:ejoan
ID: 12181032
Hey JakobA. That did it! I guess it didn't like the parenthesis. THANKS!
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

914 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now