3
I have a database in which I need to do a search based on the keywords, regardless of the order. See the complete table below:
+----+-----------------------+
| id | description |
+----+-----------------------+
| 1 | joão de santo cristo |
| 2 | eduardo e mô nica |
| 3 | santo cristo joão |
| 4 | cristo santo joão |
| 5 | juazeiro do norte |
+----+-----------------------+
When I do a search with using LIKE "%joão%cristo%"
the result is:
+----+-----------------------+
| id | description |
+----+-----------------------+
| 1 | joão de santo cristo |
+----+-----------------------+
To query search only result according to word order, first joão
accompanying anything and second cristo
. I would like the return to be this way below regardless of the order of the words. See:
+----+-----------------------+
| id | description |
+----+-----------------------+
| 1 | joão de santo cristo |
| 2 | santo cristo joão |
| 3 | cristo santo joão |
+----+-----------------------+
How would the query to search the database regardless of word order?
I believe this solves: http://stackoverflow.com/questions/32873328/sql-search-for-words-in-any-order
– Miguel
@Miguel took a look at the link, but it’s not solving the problem. The answer there seemed a nice approach, but in my case here is not returning as desired. I will do some more research here.
– viana