Suppose I have a statement like the following
select * from table where column in (select other_column from other_table)
but I would like this to match only when column “binary” equals other_column. Sort of like “binary like” but for the “in” operator.
I hope the question is clear.
Thanks 🙂
You can do:
or
But the performance of both of those will be awful because you’re asking mysql to do a type conversion on all values before it can compare.
It’s better to re-write the query as a JOIN as another comment suggested, but then you still have the issue of joining on a value that you’re doing a type conversion on, and you can’t use an index.
Better than that is if you want case sensitive or exact comparisons on this field, then change the charset in the table to BINARY for the columns, or use a collation with _cs
As usual the manual will tell you all of this MySQL Character sets and Collations