Keating
Keating

Reputation: 3530

what's wrong in this sql?

select id from dm_unit where aa like '%'||?||'%'  

Upvotes: 0

Views: 112

Answers (5)

mcha
mcha

Reputation: 2998

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

Upvotes: 0

Dr. Rajesh Rolen
Dr. Rajesh Rolen

Reputation: 14285

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)

Upvotes: 1

René Nyffenegger
René Nyffenegger

Reputation: 40499

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%'.

Upvotes: 1

karim79
karim79

Reputation: 342635

The inner quotes need to be escaped?

select id from dm_unit where aa like '%\'||?||\'%'

Upvotes: 2

Oded
Oded

Reputation: 498924

You need to escape the internal single quotes, this can be done by doubling them:

select id from dm_unit where aa like '%''||?||''%'  

Upvotes: 1

Related Questions