mysql 映射插件中 $ # 的区别

$简单的字符串替换,应用场景: 传数据库对象:如表名  select * from ${tableA} where.......

tableA传入 user_info_tab ---------> select * from user_info_tab

#预编译 对替换的字段总是加上 ‘’  

select * from tableB where t_user_id =#{userId}

传入 xiamingqing之后

 select * from tableB where t_user_id ='xiamingqing'

如果是 select * from tableB where t_user_id =${userId}

传入 xiamingqing之后

 select * from tableB where t_user_id =xiamingqing

 

补充:

$的场景是 使用 表名或者列表的时候使用

select ${col1},${col2} from ${table}  在这种情况下使用

posted @ 2021-04-30 16:52  清明雨下  阅读(228)  评论(0)    收藏  举报