If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Inner Join execution sequence.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-21-11, 01:59
shahamit2 shahamit2 is offline
Registered User
 
Join Date: Sep 2011
Posts: 1
Inner Join execution sequence.

Hi,

Here in below mentioned query inner join between table1 and table2 returns 0 records hence join with table3 should come out within less than second time, irrespective of whether table3 contains millions records or trillian recors but that is not happening. can anyone please help me to know how this inner join works internally betwen table1 and table3.

SELECT *
FROM
table1 a
INNER JOIN
table2 b
ON a.payment_period_id = NAME_CONST('in_payment_period_id',80)
AND a.is_locked=0
AND a.payment_term_id IS NOT NULL
AND a.payment_term_id = b.payment_term_id
INNER JOIN
table3 c
ON a.ps_ad_id = c.ps_ad_id

Please see this second query here it will come out fast as subquery result set is being compared with table3.

SELECT *
FROM
(select a.ps_ad_id from
table1 a
INNER JOIN
table2 b
ON a.payment_period_id = NAME_CONST('in_payment_period_id',80)
AND a.is_locked=0
AND a.payment_term_id IS NOT NULL
AND a.payment_term_id = b.payment_term_id ) a
INNER JOIN
table3 c
ON a.ps_ad_id = c.ps_ad_id

Thanks in advance for your help.
Amit Shah.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On