56,678
社区成员
发帖
与我相关
我的任务
分享
mysql> set names 'gbk';
mysql> select HEX(convert('能力' using utf8));
+---------------------------------+
| HEX(convert('能力' using utf8)) |
+---------------------------------+
| E693BBE6A4A1 |
+---------------------------------+
mysql> set names sjis;
mysql> select HEX(convert('能力' using utf8));
+---------------------------------+
| HEX(convert('能力' using utf8)) |
+---------------------------------+
| E883BDE58A9B |
+---------------------------------+
mysql> select HEX('能力');
+-------------+
| HEX('能力') |
+-------------+
| 9497CD |
+-------------+
select hex(filename) from file_table;
....
| 35E68BBFE68D952E747874 |
| 36E794B3E8AB8B2E747874 |
| 31E883BDE58A9B2E747874 |
| 32E4BA88E683B32E747874 |
| 33E7A684E9AB982E747874 |
| 34E6A78BE7AF892E747874 |
.....
mysql>set names 'gbk';
mysql>select filename from ark_dhsm_file where cast(hex(filename) as char) like concat(‘%’,cast(hex(convert('能力' using utf8))as char),’%’)
ALTER TABLE ark_dhsm_file CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci;
select hex(filename) from ark_dhsm_file;
+------------------------------------------------------------+
| hex(filename) |
+------------------------------------------------------------+
...
36E794B3E8AB8B2E747874 ———————————(1)
...
35 rows in set (0.00 sec)
select * from file_table where locate(filename,'文字')>0;
或者
select * from file_table where filename like BINARY '%文字%';