i have a litle problem here, i try to create some AI that will response the input text, but the problem is
said that we have a database called “AI” that contain column “answer” and “question”
if i try to ask “Hey why are my mobile explode” using query
SELECT * FROM AI where question LIKE "%Hey why are my mobile explode%" LIMIT 1
And i have a database record like this…
Question | Answer
================================
Explode | because you got suck
I got nothing result from my query, but if i change the record and change the query to like this …
Query
SELECT * FROM AI where question LIKE "%explode%" LIMIT 1
Database
Question | Answer
=======================================================
Hey why are my mobile Explode | because you got suck
I got the return..
so the conclusion is, “LIKE” operand is read the value that containing the condition text…
VALUE is the value of Question column
CONDITION is the condition on LIKE conditional OPERAND
Value = ... are my mobile **explode**
Condition = **explode**
so the case above is MATCH
but , is it possible that we reverse the function?, i mean, how to read the value thats contained on condition text…
Value = ... **explode**
Condition = "....are my mobile **explode**
Thanks before, hopes someone can help me here..
Such simple queries will never work. You’d be FAR better off using a FULLTEXT index, which allows for such ‘natural language’ querying. If you can’t use fulltext for whatever reason, then you’ll have to do a large amount of pre-processing to build the query. For your first sample, it’d have to be:
and performance will be absolutely abysmal, because fully wild-carded clauses like cannot use indexes AT ALL. The more words in the question, the more full-table scans MySQL will have to do, and the longer everything will take.
By comparison, a fulltext version of the query would be
and… on a meta level, I hope the answer to that question is “why are you searching for this instead of going to the hospital to get your burns/shrapnel wounds treated?”