MySQL Forums
Forum List  »  Optimizer & Parser

Re: Optimizing (a=b and c=d) OR (e=f and g=h)
Posted by: KimSeong Loh
Date: July 20, 2006 05:29PM

You would want a UNION and not a JOIN.

You can covnert that into a UNION
SELECT * FROM relationships WHERE (class1='News' AND id1=52)
UNION
SELECT * FROM relationships WHERE (class2='News' AND id2=52);

If you use MySQL 5, it has a merged index optimization which may help your original statement.

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Optimizing (a=b and c=d) OR (e=f and g=h)
1770
July 20, 2006 05:29PM


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.