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 iftitle like %string_introduced% or autho开发者_开发百科r 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?
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:
- Does Microsoft Access have Full Text Search?
精彩评论