Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
誰かが'%'私のSQLでそれと比較するフィールドにを渡すと、su.username LIKE CONCAT('%', email ,'%'))すべての行が返されます。のようになってしまいsu.username LIKE CONCAT('%%%')ます。とにかくこれを回避することはできます'%'か?
'%'
su.username LIKE CONCAT('%', email ,'%'))
su.username LIKE CONCAT('%%%')
エスケープしたいという意味なので、何かではなく%リテラルと一致すると思います。%
%
その場合、必要なのは次のとおりです。
... su.username LIKE CONCAT('%',REPLACE(email,'%','\\%'),'%')
%をエスケープする必要があるため、文字通り'%'と一致します
select * from mytable where mycol like '%\%%';