Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

select problem

 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a field that has a sentence

i want to query the database to find all records with exactly that word within any sentence in that column

for example 1 wanna find the word "its"

the sentence:

"today its gonna rain"

my sql:

select * from table x where column y like '%its%'

this wont work

what am i doing wrong?

thanks in advance
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds OK to me (given that you're using proper syntax for the table and column names.) What flavor of "this won't work" are we talking about (i.e., what happens when you do it?)
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i expressed myself incorrectly

imagine i'm looking for the word "ra"

if in the same column (in any other entry) i have the word "rain", or "ramses", i get all of them instead of only getting the exact word "ra", for which i searched...

hope i made myself clear
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is there any words before "rain" and "ramses" ?
 
miguel lisboa
Ranch Hand
Posts: 1281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
depends: may be yes and may be no - one does not know whaat users input...
 
Somnath Mallick
Ranch Hand
Posts: 483
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
miguel lisboa wrote:select * from table x where column y like '%its%'


I think this should work. I tried with some of my tables and they gave the results fine! What problems are you facing when you run this query?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic