0
SELECT
partner_id, click_date, sum(clicks) as clicks
FROM
daily_metric
LEFT JOIN transaction ON daily_metric.partner_id = transaction.partner_id
FORCE INDEX (click_date_index) WHERE click_date BETWEEN :ycp0 AND :ycp1
GROUP BY partner_id , click_date) 

I have wrond syntacs :

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FORCE INDEX (click_date_index) WHERE click_date BETWEEN '2014-09-01' AND '2014-0' at line 26.

Index is used to where clause, what is wrong with my syntacs ?

1 Answer 1

1

Try this since he FORCE/USE/IGNORE goes after the table name you are joining:

SELECT
partner_id, click_date, sum(clicks) as clicks
FROM
daily_metric
LEFT JOIN transaction
FORCE INDEX FOR JOIN (click_date_index) ON daily_metric.partner_id = transaction.partner_id 
WHERE click_date BETWEEN :ycp0 AND :ycp1
GROUP BY partner_id , click_date) 
Sign up to request clarification or add additional context in comments.

1 Comment

You understand not correct this index is NOT for Join, it's for daily_metric table

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.