aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes LIKE operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "LIKE operator" Watch "LIKE operator" New topic
Author

LIKE operator

Faraz Ali
Ranch Hand

Joined: May 15, 2008
Posts: 108
Hi,

I want to create a named query, which will return all the names which starts with "ABC", similar to the query below:
select * from customer where name like 'ABC%'

or, if i the string 'ABC' is stored in a variable, than above query becomes:
select * from customer where name like name+'%'

I write a named query like this:
select c from customer c where name like :name

its working, but its not waht i want, when i changed the above named query to below:
select c from customer c where name like :name%

Above query gives exception. How to do such thing?
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

You don't want to append the '%' directly to the name variable, when calling setParameter ?


[My Blog]
All roads lead to JavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: LIKE operator