Solved

Triple Inner Join Query Freezes

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
As a database administrator, you may need to audit your table(s) to determine whether the data types are optimal for your real-world data needs.  This Article is intended to be a resource for such a task. Preface The other day, I was involved …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
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.

747 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