tags:

views:

91

answers:

5
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
+2  A: 

The inner quotes need to be escaped?

select id from dm_unit where aa like '%\'||?||\'%'
karim79
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
@Alvaro G. Vicario - that is a sound point.
karim79
+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
+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
A: 

Hello, sorry i am not giving an answer I just want to understand why not to use : LIKE '%?%'

mcha
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
Thanks James :)by the way, i dont find how to comment the question instead of post an answer
mcha