0

I want to find all movies without age rating (Rating G) with "Deleted Scenes" as Special Feature in the sakila db. My code looks like this:

SELECT *
FROM film f 
WHERE rating = "G" AND special_features IN ('Deleted Scenes')
; 

The problem is in the special_features column because it does not only contain Deleted Scenes but also e.g. 'Making of, Deleted Scenes,..', so the equal sign does not work for deleted scenes. I tried IN() but it gives me the same answer as the equal sign case.

Can someone help me?

Christian
  • 6,070
  • 11
  • 53
  • 103
Lydica
  • 11
  • 2
  • 5
    `AND special_features LIKE '%Deleted Scenes%'`? – jarlh Dec 13 '20 at 19:39
  • 2
    Provide sample data and desired results. – Gordon Linoff Dec 13 '20 at 19:39
  • Wow, thank you jarlh. I feel like a big idiot. Forgetting about %. Thank you very much! – Lydica Dec 13 '20 at 19:45
  • 1
    I'm not an SQL expert by far, but I'm pretty sure having to do a full text search over (part of) a column isn't very performant... If this is MySQL, maybe [`FIND_IN_SET`](https://dev.mysql.com/doc/refman/8.0/en/set.html) would offer slightly better performance? `AND FIND_IN_SET('Deleted Scenes',special_features)>0;` – Christian Dec 13 '20 at 19:54

0 Answers0