您的位置:首页 > 其它

Mybatis参数传递记录

2014-12-19 14:09 239 查看
当对mybaits进行参数传递时

#{paramter} 表示一个'?'

${paramter}表示替换

例如:

updateid=123

infoids=123,123

select * from test where updateid=#{updateid} and infoids in (#{infoids})

mybaitis打印出来的sql是 select * from test where updateid=? and infoids in (?)

select * from test where updateid=#{updateid} and infoids in (${infoids})

mybaitis打印出来的sql是 select * from test where updateid=? and infoids in (123,123)

上面的2个sql的结果是不一样的

第一个sql可以理解为select * from test where updateid=123 and infoids in (‘123,123’) 123,123作为一个字符串去传递

第二个sql可以理解为select * from test where updateid=123 and infoids in (123,123)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: