Solved

Triple Inner Join Query Freezes

Posted on 2004-09-26
3
3,371 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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

Creating and Managing Databases with phpMyAdmin in cPanel.
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

623 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