Can someone explain me why with that query:
SELECT * FROM `tags` WHERE (tag IN (\'willa-lentza\', 2016))
it return me all rows from tags<
I cannot reproduce this behaviour, but it seems that your varchars
get casted into a DOUBLEs
and not the other way around.
In this case, the query turns into this:
SELECT *
FROM tags
WHERE CAST(tag AS DOUBLE) /* =0 for non-numeric tags */ IN (CAST('willa-lentza AS DOUBLE) /* = 0 */, 2016)
which is always true for all non-numeric tags.
Could you please run EXPLAIN EXTENDED SELECT ...
on this statement and post the warning here?
To confirm this behavior, you can add another numerical tag:
INSERT
INTO tags
VALUES (6, '1000')
This tag should be returned by neither of the queries.
To avoid this, just always enclose your constants into single quotes so that they are parsed as CHARs