像单引号和等号子句不起作用 [英] apostrophe like and equal clause not working
问题描述
我有一个名为tags
的table
,它包含如下条目.
I have one table
named tags
and it contain entry which is as below.
ID
Name
Created Date
10
limit\'s
2013-06-27 05:18:35
ID
Name
Created Date
10
limit\'s
2013-06-27 05:18:35
现在,我想使用查询来搜索limit's
,但无法搜索记录.
Now i want to search for limit's
using query but could not search record.
对于我尝试过的事情.
'SELECT id FROM tags AS Tag WHERE name = "%'. urlencode($adTag) .'%" LIMIT 0,1'
'SELECT id FROM tags AS Tag WHERE name LIKE "%'. htmlspecialchars($adTag) .'%" LIMIT 0,1'
'SELECT * FROM tags AS Tag WHERE name LIKE "%'. $adTag .'%" OR REPLACE(name,'''','') LIKE "%'. $adTag .'%"'
'SELECT id FROM tags AS Tag WHERE name LIKE "%'. mysql_real_escape_string( stripslashes($adTag)) .'%" LIMIT 0,1'
'SELECT id FROM tags AS Tag WHERE name LIKE "%'. mysql_real_escape_string($adTag) .'%" LIMIT 0,1'
$adTag
动态出现的位置,其值为limit's
.上面已经尝试过了,但是没有一个起作用.
Where $adTag
is coming dynamically and its value is limit's
. Above are tried but none of that worked.
让我知道我在做什么错,以便我可以更正mysql.
Let me know what i am doing wrong so i can correct mysql.
谢谢.
推荐答案
在完成了许多Google搜索工作之后,我终于完成了这项工作.
Well after so many googleing work done i finally get this working.
下面是我的解决方法.
SELECT *
FROM tags
WHERE `name` = 'limit\\''s'
LIMIT 0 , 30
它的运作就像魅力.希望这对其他极客有帮助.
Its worked like charm. Hope this will help in future for other geeks.
这篇关于像单引号和等号子句不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!