Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HQL + LIKE + _

 
kri shan
Ranch Hand
Posts: 1479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using LIKE in HQL. Hence it takes all records that matches LIKE including _(under score). But i want to omit under score(_). How ?
 
kri shan
Ranch Hand
Posts: 1479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any update ?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you tell us what exactly you're trying to do? If you want to match all strings containing an underscore, that character will need to be in the LIKE phrase. What would be the point of keeping it out of the match pattern?
 
kri shan
Ranch Hand
Posts: 1479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf, LIKE should match with only characters, not any special characters(_).
 
kri shan
Ranch Hand
Posts: 1479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf Dittmer, Any update ?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about adding another phrase like "... AND NOT LIKE '%_%'"? Or -for better performance- work with the SQL equivalent of String.indexOf.

Or are there other special characters you want to exclude as well?

By the way, please don't ask for answers from specific people. It makes others -who may have more to contribute- feel excluded and unwelcomed.
 
kri shan
Ranch Hand
Posts: 1479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to exclude all special characters. How (not using AND NOT LIKE '%_%'")?
 
kri shan
Ranch Hand
Posts: 1479
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Any update ???
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic