select id from dm_unit where aa like '%'||?||'%'
A:
You need to escape the internal single quotes, this can be done by doubling them:
select id from dm_unit where aa like '%''||?||''%'
Oded
2010-04-26 10:05:59
+2
A:
The inner quotes need to be escaped?
select id from dm_unit where aa like '%\'||?||\'%'
karim79
2010-04-26 10:06:13
Or doubled... Or perhaps || is the concatenation operator and ? is a place holder for prepared statements. That's why we need to know the SQL dialect.
Álvaro G. Vicario
2010-04-26 16:08:17
@Alvaro G. Vicario - that is a sound point.
karim79
2010-04-26 16:21:31
+1
A:
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 ?
and the placeholder's value should later on be bound to something like '%foobar%'
.
René Nyffenegger
2010-04-26 10:08:12
+1
A:
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)
Rajesh Rolen- DotNet Developer
2010-04-26 10:30:38
A:
Hello,
sorry i am not giving an answer I just want to understand why not to use : LIKE '%?%'
mcha
2010-04-26 12:12:22
Because it's not a valid placeholder, since the question mark is contained within the string and therefore won't be understood. Also if you have a question that refers to someone elses answer you should leave a comment instead of making a new answer.
James
2010-04-26 12:15:45
Thanks James :)by the way, i dont find how to comment the question instead of post an answer
mcha
2010-04-26 12:48:33