0

Now, heading might be a bit misleading. If that is the case forgive me as I cannot think of best heading!

i have database of books, that is e-books. Each table have page number and contents (to simulate true book). The problem is, I have to search for a word in the book and return page number and contents. I know LIKE '%mykeyword%' helps to some extent but it returns much unneeded stuffs. Eg if the keyword is Goa it will bring goalkeeper, goat et al. I want to be able to get pages which contains exactly word Goa and ignore others. Which query am I supposed to use. I have run out of Ideas so, I need your help

3
Contributors
6
Replies
7
Views
6 Years
Discussion Span
Last Post by Stefano Mtangoo
0

How about searching with REGEX.

$query = "SELECT * FROM table WHERE column REGEXP '[[:<:]]" . $word . "[[:>:]]'"

Edited by pritaeas: n/a

0

I didn't said that I use SQLite3, however I will search to see if those solutions are available with SQLite

0

From the sqlite site:
The like() function is used to implement the "Y LIKE X [ESCAPE Z]" expression. If the optional ESCAPE clause is present, then the like() function is invoked with three arguments. Otherwise, it is invoked with two arguments only. Note that the X and Y parameters are reversed in the like() function relative to the infix LIKE operator. The sqlite3_create_function() interface can be used to override the like() function and thereby change the operation of the LIKE operator. When overriding the like() function, it may be important to override both the two and three argument versions of the like() function. Otherwise, different code may be called to implement the LIKE operator depending on whether or not an ESCAPE clause was specified.

I do not know about SQLite, so can't give an example, but perhaps you can find one (looks like a function in C).

Edited by pritaeas: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.