在MySQL中用撇号搜索记录,例如查询 [英] Search record with apostrophe in mysql like query

查看:75
本文介绍了在MySQL中用撇号搜索记录,例如查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有类似这样的mysql查询.

I have mysql query something like this.

SELECT * from users where username LIKE "%test\'s%"

并具有字段名称为usernameusers数据库表.

And have users database table with field name username.

users表中有1条记录,用户名为test\'s,现在我想根据username从用户表中查询获取记录的查询.但它不起作用.

And there is 1 record in users table with username test\'s and now i want to fire query for fetch record from users table according to username. but it's not working.

请帮助我解决这个问题.

Please help me to come out from this issues.

您的帮助将不胜感激.

推荐答案

好,我遇到了同样的问题,并使用下面的代码解决了这个问题.

Well i had same problem and i solved it using below code.

SELECT *
FROM users
WHERE `username` = 'test\\''s'

希望这对您也有用.

这篇关于在MySQL中用撇号搜索记录,例如查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆