BoostedMonkey BoostedMonkey - 1 year ago 76
MySQL Question

SQL condition statement for strings

I am trying to Write a query that produces the title of every action film with a rating of PG-13, R, or NC-17.

Here is my SQL:

SELECT title
FROM film
INNER JOIN film_category ON film.film_id = film_category.film_id
INNER JOIN category ON film_category.category_id = category.category_id
WHERE = "Action"
WHERE film.rating = "PG-13" OR "R" OR "NC-17";

I believe the problem is in my syntax in my film.rating conditioning. I am new to SQL. I would appreciate if someone could show me in the right direction!

Answer Source

Try the following:

SELECT title 
FROM film f INNER JOIN film_category fc ON f.film_id = fc.film_id
    INNER JOIN category c ON fc.category_id = c.category_id
WHERE = 'Action'
AND f.rating IN ('PG-13', 'R', 'NC-17');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download