Solved

Triple Inner Join Query Freezes

Posted on 2004-09-26
3
3,370 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

Foreword This article was written many years ago, in the days when PHP supported the MySQL extension (http://php.net/manual/en/function.mysql-connect.php).  Today (http://php.net/manual/en/migration70.removed-exts-sapis.php) you would not use MySQL…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

751 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