You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Ra...@emc.com on 2005/10/26 17:31:18 UTC

How to set up a select map

Hi, 
I want to do a pattern matching search on the database; for e.g select all
rows that have text "ab" in them. The text can occur independantly or
embedded. How do I do a pattern matching Select with the IBATIS map?
Thanks,

Mithra Rajah 



Re: How to set up a select map

Posted by Larry Meadors <lm...@apache.org>.
Three ways:

1) Use "where value like #property# and put the pattern in your property.

2) Use "where value like '%' || #property# || '%'and put the value in your
property.

3) Use "where value like '%$property$%" and put the value in your property.

The last option will open you you up to SQL injection, and is generally bad
practice. It also does not take advantage of some database vendors'
execution plan caching.

Larry


On 10/26/05, Rajah_Mithra@emc.com <Ra...@emc.com> wrote:
>
> Hi,
> I want to do a pattern matching search on the database; for e.g select all
> rows that have text "ab" in them. The text can occur independantly or
> embedded. How do I do a pattern matching Select with the IBATIS map?
> Thanks,
>
> Mithra Rajah
>