Ronan Lucio wrote:
<snip>
The problem is that if I use OR in the where clause, MySQL won't use the indexes in the row_id column.
Yes, it will, as long as the OR conditions are on the *same* column.
WHERE row_id IN (2,5,7)
and
WHERE (row_id = 2 OR row_id = 5 OR row_id = 7)
are equivalent. I prefer IN because it is easier to type and read, but mysql should treat them the same.
If you tried this with OR and mysql did not use the index, my guess is that you forgot the parentheses:
SELECT * FROM table WHERE client_id = 1 AND row_id = 2 OR row_id = 5 OR row_id = 7;
AND has higher precedence than OR, so mysql would see that as
WHERE (client_id = 1 AND row_id = 2) OR row_id = 5 OR row_id = 7;
which won't use an index and isn't what you meant.
Michael
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]