您的位置:首页 > 编程语言 > Python开发

python mysql like查询的写法

2013-03-18 20:26 225 查看
1 外面双引号,里面单引号不要转义,%要转义%%。

cur.execute("select * from tag_users where name like '%%"+name+"%%'")


2 或者以参数的形式,2种不同的参数传法见引用
http://blog.csdn.net/shellshine/article/details/8207448 python向mysql插入特殊字符

cur.execute("select * from tag_users where name like '%%%s%%'"%(word))
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: