查询全表数据时好像没有问题
1 2 3 4 5 6 7 |
root@localhost:mysql3306.sock [test]> select * from t1; +----+------------+--------+----------+ | ID | PlatFormId | GameId | GameName | +----+------------+--------+----------+ | 1 | 163game | 1 | 游戏1 | +----+------------+--------+----------+ 1 row in set (0.00 sec) |
按条件查询时
1 2 |
root@localhost:mysql3306.sock [test]> select * from t1 where PlatFormId = '163game'; Empty set (0.00 sec) |
等值查询查不到对应的记录?
1 2 3 4 5 6 7 |
root@localhost:mysql3306.sock [test]> select * from t1 where PlatFormId like '%163game%'; +----+------------+--------+----------+ | ID | PlatFormId | GameId | GameName | +----+------------+--------+----------+ | 1 | 163game | 1 | 游戏1 | +----+------------+--------+----------+ 1 row in set (0.00 sec) |
模糊查询就查到了,是不是这个列的数据有什么问题?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
root@localhost:mysql3306.sock [test]> select HEX(PlatFormId) from t1 where PlatFormId like '%163game%'; +----------------------+ | HEX(PlatFormId) | +----------------------+ | EFBBBF31363367616D65 | +----------------------+ 1 row in set (0.00 sec) root@localhost:mysql3306.sock [test]> select HEX('163game'); +----------------+ | HEX('163game') | +----------------+ | 31363367616D65 | +----------------+ 1 row in set (0.00 sec) |
果然是数据有问题
mysql -S /tmp/mysql3306.sock -uroot test -e "select PlatFormId from t1 where PlatFormId like '%163game%'" > tmp.txt,导出后用vim打开文件看看
1 2 |
PlatFormId <span style="color: #0000ff;"><feff></span>163game |
多出一个<feff>,这是什么东东?原来这是utf8 bom的问题,windows下文件编码要注意一个这问题