Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Triple Inner Join Query Freezes

Posted on 2004-09-26
3
Medium Priority
?
3,375 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 2000 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

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

916 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