So if I have a table
CREATE TABLE examples ( id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, external_id CHAR(12) NOT NULL, data INT(11), INDEX (external_id)) Engine=InnoDB;
and I query it like so:
SELECT * FROM examples WHERE external_id = 1
I can’t use the index, because MySQL thinks it must coerce the external_id column to an INT in order to evaluate the where clause. Is there any good reason why it just doesn’t coerce the constant into a CHAR(12)?