mysql数据库转义符写SQL后一直转义报错

我想写成如果username=admin,就跳过,否则等于查询的值。

但是数据库里的username存储格式是:公司\姓名,如fanruan\zhangsan 这种格式。

转义一直有问题 求救

这样也不行:   ${if(fine_username="admin","and 1=1", "and replace(u.username,'xincheng\\','')='"+replace(fine_username,'xincheng\\','')+"'")}  这样也不行: ${if(fine_username="admin","and 1=1","and username = 'xincheng'+'\\\\'+"replace(fine_username,'xincheng\\','')" ")}

image.png

FineReport 用户T0087430 发布于 2021-8-10 17:17
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共1回答
最佳回答
0
zsh331Lv8专家互助
发布于2021-8-10 22:39

select replace(replace("fanruan\zhangsan","fanruan",""),char(92),"") as t

-- 方法不唯一,灵活扩展!

image.png

  • 2关注人数
  • 347浏览人数
  • 最后回答于:2021-8-10 22:39
    请选择关闭问题的原因
    确定 取消
    返回顶部