两种方式,一个 是转bigint,一个是转binary
mysql> select t1.id id1, t1.name name1, t2.id id2, t2.name name2
-> from t1,t2
-> where cast(t1.name as unsigned) = t2.name;
+-----+--------------------+-----+--------------------+
| id1 | name1 | id2 | name2 |
+-----+--------------------+-----+--------------------+
| 1 | 123456789012345611 | 2 | 123456789012345611 |
| 1 | 123456789012345611 | 1 | 123456789012345611 |
| 3 | 123123 | 3 | 123123 |
+-----+--------------------+-----+--------------------+
3 rows in set (0.01 sec)
mysql> select t1.id id1, t1.name name1, t2.id id2, t2.name name2
-> from t1,t2
-> where t1.name = cast(t2.name as binary);
+-----+--------------------+-----+--------------------+
| id1 | name1 | id2 | name2 |
+-----+--------------------+-----+--------------------+
| 1 | 123456789012345611 | 2 | 123456789012345611 |
| 1 | 123456789012345611 | 1 | 123456789012345611 |
| 3 | 123123 | 3 | 123123 |
+-----+--------------------+-----+--------------------+
3 rows in set (0.03 sec)