# why coerce the column instead of a constant?

**URL:** <https://forums.percona.com/t/why-coerce-the-column-instead-of-a-constant/5548>\
**Category:** Other MySQL® Questions\
**Created:** [April 16, 2017, 4:18am UTC](https://forums.percona.com/t/why-coerce-the-column-instead-of-a-constant/5548 "2017-04-16T04:18:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![takeshi14121990](https://avatars.discourse-cdn.com/v4/letter/t/3da27b/32.png) [@takeshi14121990](https://forums.percona.com/u/takeshi14121990)\
**Post date:** [April 16, 2017, 4:18am UTC](https://forums.percona.com/t/why-coerce-the-column-instead-of-a-constant/5548/1 "2017-04-16T04:18:12Z")

</div>

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)?

Just curious.
