Home > Backend Development > PHP Tutorial > 请问个MYSQL的问题

请问个MYSQL的问题

WBOY
Release: 2016-06-23 14:24:57
Original
812 people have browsed it


如果数据库里存的是短字符串:
AB
BC
CD

那么我手上的词是长字符串,例如 ABCD,那么SQL应该怎么写,来匹配出该字符包含有数库里的短词记录?要连着的,要用CONCAT吗?

另外,保存这些短字符串到数据库的时候,如何处理才能安全,会不会有注入之类的隐患?
谢谢


回复讨论(解决方案)

是的
select * from tbl_name where 'ABCD' like concat('%', field_name, '%')

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template