MySQL Forums
Forum List  »  Optimizer & Parser

Re: SUBQUERY PROBLEM
Posted by: Jay Pipes
Date: February 08, 2006 03:59PM

Odimar,

To help us diagnose, would you post the results of the following code, run from the command line client? Thanks!

EXPLAIN SELECT DISTINCT ReportID, ReportName, FromDate, ToDate, Market, Entity, Submarket, CurrencyCode, Customer
FROM nm1_customer_exempt
WHERE FromDate >= '2005-12-01 00:00:00' and ToDate <= '2005-12-31 00:00:00'
and CONCAT(Market,Entity,Submarket,CurrencyCode,Customer)
NOT IN (SELECT DISTINCT CONCAT(nce.Market,nce.Entity,nce.Submarket,nce.CurrencyCode,nce.Customer)
FROM nm1_customer_exempt nce
WHERE nce.FromDate >= '2005-11-01 00:00:00' and nce.ToDate <= '2005-11-30 00:00:00') \G

EXPLAIN SELECT
e1.ReportID
, e1.ReportName
, e1.FromDate
, e1.ToDate
, e1.Market
, e1.Entity
, e1.Submarket
, e1.CurrencyCode
, e1.Customer
FROM nm1_customer_exempt e1
LEFT JOIN nm1_customer_exempt e2
ON e1.Market = e2.Market
AND e1.Entity = e2.Entity
AND e1.Submarket = e2.Submarket
AND e1.CurrencyCode = e2.CurrencyCode
AND e1.Customer = e2.Customer
AND e2.FromDate >= '2005-11-01 00:00:00'
AND e2.ToDate <= '2005-11-30 00:00:00'
WHERE e1.FromDate >= '2005-12-01 00:00:00'
AND e1.ToDate <= '2005-12-31 00:00:00'
AND e2.ReportID IS NULL \G

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote


Subject
Views
Written By
Posted
2998
February 07, 2006 04:21PM
2022
February 07, 2006 04:45PM
1927
February 07, 2006 04:52PM
2027
February 08, 2006 04:57AM
Re: SUBQUERY PROBLEM
1902
February 08, 2006 03:59PM
1966
February 08, 2006 08:37AM
2130
February 13, 2006 11:06AM
2075
February 13, 2006 11:17AM
1967
February 13, 2006 11:22AM
1911
February 13, 2006 12:16PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.