I have been struggling with getting an opposite search in MySQL.
Here is a sample database:
+-------+--------+
| name | fruits |
+-------+--------+
| Jimmy | pear |
| Jimmy | apple |
| Jimmy | peach |
| Becky | pear |
| Garry | apple |
| Garry | pear |
+-------+--------+
What I’m trying to get is names of all people that did not eat apple. When I do query searching for WHERE fruits NOT LIKE "%apple%" I get not only Becky (which is the only one who did not eat it), but also two fields of Jimmy and one of Garry, because there were other occurrences where they ate something else.
How should I write a query?
this is one possible approach