[英]Codeigniter SQL query not working with SPECIAL CHARACTERS in WHERE clause
[英]SQL query IN clause: How to escape special characters when passing a list
我在查询中传递了日记列表,该查询的日记名称中包含特殊字符,例如&,-'()。 这是我的查询内容:
select alt_id, citation.doi, citation.journal, citation.volume,
citation.issue, citation.pubdate, citation.title
from ALT_2018
where citation.journal in ('Mechanics & Astronomy', 'Women's Health', 'Current
Directions in Psychological Science (Sage Publications Inc.)', 'Cement &
Concrete Composites', 'Journal of Heart & Lung Transplantation', 'Infection control
and hospital epidemiology (Online)', 'Journal of Research on Adolescence
(Blackwell Publishing Limited)', 'Ophthalmic & Physiological Optics', 'Brain
Structure & Function', 'New Solutions: A Journal of Environmental &
Occupational Health Policy', 'European Physical Journal B -- Condensed
Matter')
我尝试使用反斜杠来转义特殊字符,但是它不起作用,并且由于列表包含2000多种期刊,所以我也无法手动进行。 请帮帮我。
PS我正在Studio3T中使用SQL查询扩展,因为数据保存在MongoDB中并且为json格式
您可以在此处阅读有关MySQL字符串文字中的特殊字符的信息: https : //dev.mysql.com/doc/refman/8.0/en/string-literals.html
如果需要使用撇号字符,则可以使用以下方法之一:
'Women\'s Health'
'Women''s Health'
"Women's Health" -- only if sql_mode is not ANSI or ANSI_QUOTES
这些是选项。 我不知道您的意思是“它没有用”,所以我不建议如何解决它。 我不使用Studio3T,所以我无法猜测是什么导致您无法使用这些解决方案之一。
MySQL字符串文字中的&
字符没有什么特别的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.