• PHP Help PHP Databases
  • MySQL ignores indexes if query contains conditions "greater than" or "smaller than"

Hello,

Does anyone know why MySQL is not using indexes in queries with conditions "greater than" or "is not empty":

select from table where col1='$col1' and col2 !='';
select from table where col1='$col1' and col2 > '0';

Indexes are used only if query contains condition "equal to":

select from table where col1='$col1' and col2 ='$col2';

Don't know how can I use indexes if I need to select columns where value is greater than something or value is not empty 🙁

    a month later

    Both columns are INT.

      Write a Reply...