1.截取字符串
left(str, length),right(str, length),substring(str, pos, length)
原文:http://www.jb51.net/article/27458.htm
2.显示查询结果的前100条
select * from tbl limit 100;
3.将varchar转换成int
类型:BINARY、CHAR、DATE、DATETIME、DECIMAL、SIGNED [INTEGER]、TIME、UNSIGNED [INTEGER]
select server_id from cardserver where game_id = 1 order by CAST(server_id as SIGNED) desc limit 10
select server_id from cardserver where game_id = 1 order by CONVERT(server_id,SIGNED) desc limit 10
参考:http://blog.sina.com.cn/s/blog_4550f3ca0101qa3l.html
4.python 读入中文txt乱码
Python连接MySQL是加上参数 charset=utf8
参考:http://ju.outofmemory.cn/entry/126