-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Is there a way to mimic SQL LIKE in WHERE clause?
PostPosted: Sat Apr 09, 2005 11:08 pm 
Newbie

Joined: Thu Nov 04, 2004 12:52 am
Posts: 4
I'm not sure if this is a feature of "generic" SQL or not, but Microsoft's SQL Server allows criteria in a WHERE clause to be specified using the keywork LIKE and wildcards. Is there a way to do this with HQL?

For example, with Transact-SQL, I could write:

Code:
SELECT * FROM PEOPLE WHERE FIRST_NAME LIKE 'J%'


which would retrieve a list of records from the PEOPLE table where the first name started with the letter J. SQL Server uses the % as the wildcard character - again, not sure how this compares with other dialects of SQL.

Anyone know of a comparable technique using HQL? I'm trying to find records in a long list where I only part of an alphanumeric identifier, so I'd like to be able to allow the user to supply a fragment of the identifier and return partial matches.

Thanks in advance.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 10, 2005 3:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
did you ever try ? or read the docs ? ,)


Searching in docs for % and I found:

select cat.name from DomesticCat cat
where cat.name like 'fri%'

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.