Good, I have a problem with the Mysql I have a very small table:
CREATE TABLE 'Prueba' (
'idTipoCliente' int(10) COLLATE utf8_general_mysql500_ci NOT NULL,
'descripcion' varchar(20) COLLATE utf8_general_mysql500_ci NOT NULL,
'observacion' varchar(255) COLLATE utf8_general_mysql500_ci NOT NULL,
PRIMARY KEY ('idTipoCliente')
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_general_mysql500_ci;
with only these few rows
INSERT INTO 'Prueba' VALUES ('1', 'Cliente1', 'datos1');
INSERT INTO 'Prueba' VALUES ('2', 'Cliente2', 'datos2');
INSERT INTO 'Prueba' VALUES ('3', 'Cliente3', 'datos3');
Then I'm trying to make a simple query like this:
Explain SELECT * FROM 'Prueba' WHERE 'idTipoCliente' in (1,2,3)
and I get this result
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE Prueba ALL PRIMARY NULL NULL NULL 3 Using where
That is not recognizing the KEY (PRIMARY), but if I make a query like this
Explain SELECT * FROM 'Prueba' WHERE 'idTipoCliente'>=1;
Or this
Explain SELECT * FROM 'Prueba' FORCE Index(PRIMARY) WHERE 'idTipoCliente' in (1,2,3);
if it recognizes the KEY
My problem is that the Key is lost when I use "where in", because I am wanting to use this table in a more complex query with several other tables and Inner Join, and the solution I see is to use FORCE INDEX, but I wanted to know if there is another solution.