views:

42

answers:

1

Hi!

I have this website to search for books, there is only ONE text field, to search by words, title author, whatever it types.

if the name of the book is hello goodbye, and the author is A. Jones

if i type hello
i get the result of the book (my query is using the like statement)
i check if title like %string_introduced% or author like %string_introduced% using sql in java

the problem is when i introduce in the textfield "hello jones" it tells me there are no results

The problem is that this is translated to where title like %hello jones% or author like %hello jones%, this is why it doesn't work

Is there a way to do this in sql, without having to do a split of the string?

+2  A: 

No, I think you will have to split the string.

WHERE (title LIKE '%hello%' OR title LIKE '%jones%')
OR    (author LIKE '%hello%' OR author LIKE '%jones%')

The parentheses aren't necessary here. They are just for clarity.

Related:

Mark Byers
I'm not seeing the relevance of the cited article.
David-W-Fenton
@David-W-Fenton: The relevance is that Access *doesn't* have full text search. If it did I would have suggested that instead of using LIKE.
Mark Byers
The interesting part of that question is *If Access doesn't have Full Text, what is the best alternative to achieve the same objective of Full Text Search?* Unfortunately the only useful answer there seems to be to switch to another database.
Mark Byers
But this particular question isn't about full-text search.
David-W-Fenton