File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes select problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Bookmark "select problem" Watch "select problem" New topic

select problem

miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
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

java amateur
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24199

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?)

[Jess in Action][AskingGoodQuestions]
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
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

Joined: Dec 06, 2005
Posts: 1323

is there any words before "rain" and "ramses" ?

[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
depends: may be yes and may be no - one does not know whaat users input...
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 482
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?
I agree. Here's the link:
subject: select problem
It's not a secret anymore!