MySQL Forums
Forum List  »  General

Re: Join Syntax Confusion
Posted by: Shawn Taylor
Date: May 19, 2011 07:04AM

OK, here is the result of show warnings.

SELECT `oca`.`journal`.`xjStore` AS `xjStore`,`oca`.`cofile`.`coPbBusName` AS `coPbBusName`,`oca`.`journal`.`xjCloseDate` AS `xjCloseDate`,`oca`.`journal`.`xjNonNetSales` AS `xjNonNetSales`,`oca`.`journal`.`xjTaxCoreSales` AS `xjTaxCoreSales`,`oca`.`journal`.`xjNonTaxCoreSales` AS `xjNonTaxCoreSales`,`oca`.`journal`.`xjTaxTotal` AS `xjTaxTotal`,`oca`.`journal`.`xjFreightSales` AS `xjFreightSales`,`oca`.`journal`.`xjLaborSales` AS `xjLaborSales`,`oca`.`journal`.`xjIsClosedDoc` AS `xjIsClosedDoc`,`oca`.`journal`.`xjType` AS `xjType`,`oca`.`journal`.`xjTaxCoreReturns` AS `xjTaxCoreReturns`,`oca`.`journal`.`xjNonTaxCoreReturns` AS `xjNonTaxCoreReturns`,`oca`.`journal`.`xjDefReturns` AS `xjDefReturns`,`oca`.`journal`.`xjNewReturns` AS `xjNewReturns`,`oca`.`journal`.`xjFreightReturns` AS `xjFreightReturns`,`oca`.`journal`.`xjLaborReturns` AS `xjLaborReturns`,`oca`.`acc`.`accAcctGroup` AS `accAcctGroup`,`oca`.`journal`.`xjSubTotal` AS `xjSubTotal`,`oca`.`journal`.`xjCoreTotal` AS `xjCoreTotal`,`oca`.`journal`.`xjOverallAmt` AS `xjOverallAmt`,`oca`.`journal`.`xjCostSales` AS `xjCostSales`,`oca`.`journal`.`xjCostDefRet` AS `xjCostDefRet`,`oca`.`journal`.`xjCostNewRet` AS `xjCostNewRet`,`oca`.`journal`.`xjCostCoreSales` AS `xjCostCoreSales`,`oca`.`journal`.`xjCostCoreCredits` AS `xjCostCoreCredits`,`oca`.`journal`.`xjRebAdjCostSls` AS `xjRebAdjCostSls`,`oca`.`journal`.`xjCostCredits` AS `xjCostCredits`,`oca`.`journal`.`xjRebAdjCostCrd` AS `xjRebAdjCostCrd`,`oca`.`cofile`.`coActive` AS `coActive`,`oca`.`journal`.`xjTotal` AS `xjTotal`,`oca`.`cofile`.`coHubStore` AS `coHubStore`,`oca`.`journal`.`xjAmtAmex` AS `xjAmtAmex`,`oca`.`journal`.`xjAmtBankCard` AS `xjAmtBankCard`,`oca`.`journal`.`xjAmtCash` AS `xjAmtCash`,`oca`.`journal`.`xjAmtChange` AS `xjAmtChange`,`oca`.`journal`.`xjAmtCheck` AS `xjAmtCheck`,`oca`.`journal`.`xjAmtCoupon` AS `xjAmtCoupon`,`oca`.`journal`.`xjAmtCharge` AS `xjAmtCharge`,`oca`.`journal`.`xjAmtOther1` AS `xjAmtOther1`,`oca`.`journal`.`xjAmtOther3` AS `xjAmtOther3`,`oca`.`journal`.`xjAmtOther2` AS `xjAmtOther2`,`oca`.`journal`.`xjDepositAmt` AS `xjDepositAmt`,`oca`.`journal`.`xjPrevDeposit` AS `xjPrevDeposit`,`oca`.`journal`.`xjSHSales` AS `xjSHSales`,`oca`.`journal`.`xjSHReturns` AS `xjSHReturns`,`oca`.`journal`.`xjNetSales` AS `xjNetSales`,`oca`.`journal`.`xjStatus` AS `xjStatus`,`oca`.`journal`.`xjInvNum` AS `xjInvNum`,`oca`.`journal`.`xjNonTaxStateFee` AS `xjNonTaxStateFee`,`oca`.`journal`.`xjTaxStateFee` AS `xjTaxStateFee`,`oca`.`journal`.`xjNonTaxCIDFee` AS `xjNonTaxCIDFee`,`oca`.`journal`.`xjTaxCIDFee` AS `xjTaxCIDFee`,`oca`.`journal`.`xjNonTaxOtherFee` AS `xjNonTaxOtherFee`,`oca`.`journal`.`xjTaxOtherFee` AS `xjTaxOtherFee`
FROM `oca`.`acc` 
JOIN `oca`.`cofile` 
JOIN `oca`.`journal` 
WHERE 
(
	(`oca`.`cofile`.`coStore` = `oca`.`journal`.`xjStore`) AND 
	(`oca`.`acc`.`accNumber` = `oca`.`journal`.`xjActNumber`) AND
	(`oca`.`journal`.`xjCloseDate` >= '2010-12-1 00:00:00') AND 
	(`oca`.`journal`.`xjCloseDate` < '2010-12-16 00:00:00')
)
ORDER BY `oca`.`journal`.`xjStore`

I was unaware of this as an option. I assume this is the query re-written after coming through the optimizer?? That is a neat little trick!

The way it re-writes the joins is curious. I always thought that the 'ON colulmn = column' syntax was more efficient?? Or is it merely that the where clause stays a little cleaner if you write it that way but it changes nothing in the execution plan?

Lastly, it looks like you are correct about that wonky syntax. It changes nothing.

I love that I can post one question and learn two things!

Thanks for the help/advice.

Shawn

Options: ReplyQuote


Subject
Written By
Posted
May 18, 2011 07:55AM
Re: Join Syntax Confusion
May 19, 2011 07:04AM
May 22, 2011 09:30AM


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.