Reputation: 780
For example, I have a table like this:
----------------------------------------------------------------------------
| id | title | tags |
----------------------------------------------------------------------------
| 1 | Title 1 | funny, adventure |
----------------------------------------------------------------------------
| 2 | Title Two | funny, short, horror |
----------------------------------------------------------------------------
| 3 | Title III | funny, short, adventure |
----------------------------------------------------------------------------
How can I query that I want to include funny or short but exclude horror in the results? Like the exclude will overpower even if one of its include criteria matches?
----------------------------------------------------------------------------
| id | title | tags |
----------------------------------------------------------------------------
| 1 | Title 1 | funny, adventure |
----------------------------------------------------------------------------
| 3 | Title III | funny, short, adventure |
----------------------------------------------------------------------------
Upvotes: 1
Views: 488
Reputation: 326
Try this -
SELECT * FROM table_name WHERE NOT find_in_set('horror',tags) <> 0
Upvotes: 1