[英]what's wrong in this sql?
select id from dm_unit where aa like '%'||?||'%'
内引号需要转义吗?
select id from dm_unit where aa like '%\'||?||\'%'
您需要转义内部单引号,这可以通过将它们加倍来完成:
select id from dm_unit where aa like '%''||?||''%'
I assume you use the ?
我假设您使用?
as a placeholder. 作为占位符。 If this is the case, the query should read select id from dm_unit where aa like ?
如果是这种情况,查询应从select id from dm_unit where aa like ?
读取select id from dm_unit where aa like ?
and the placeholder's value should later on be bound to something like '%foobar%'
. 并且该占位符的值稍后应绑定到'%foobar%'
类'%foobar%'
东西。
I think you wrote \\' in your query to use single quote in your query. 我认为您在查询中写了\\'以便在查询中使用单引号。 but its not a right way. 但它不是正确的方法。 to use single quote in our query use '' (2 single quote) instead of ' (1 single quote) 要在查询中使用单引号,请使用”(2个单引号)而不是“(1个单引号)
抱歉,我没有给出答案,我只想了解为什么不使用: LIKE '%?%'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.