utf8 bom文件数据的问题

查询全表数据时好像没有问题

root@localhost:mysql3306.sock [test]> select * from t1;
+----+------------+--------+----------+
| ID | PlatFormId | GameId | GameName |
+----+------------+--------+----------+
|  1 | 163game   | 1      | 游戏1    |
+----+------------+--------+----------+
1 row in set (0.00 sec)

按条件查询时

root@localhost:mysql3306.sock [test]> select * from t1 where PlatFormId = '163game';
Empty set (0.00 sec)

等值查询查不到对应的记录?

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)

模糊查询就查到了,是不是这个列的数据有什么问题?

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打开文件看看

PlatFormId
<feff>163game

多出一个<feff>,这是什么东东?原来这是utf8 bom的问题,windows下文件编码要注意一个这问题

 

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇