1

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                       |
----------------------------------------------------------------------------
James Arnold
  • 698
  • 3
  • 9
  • 22

1 Answers1

1

Try this -

SELECT * FROM table_name WHERE NOT find_in_set('horror',tags) <> 0 
phpforcoders
  • 326
  • 1
  • 9