Back to articles
CA 32 - Filter Assignments
News

CA 32 - Filter Assignments

via Dev.to TutorialSuruthika

I started by retrieving all movies that have a rental rate greater than $3. SELECT * FROM film WHERE rental_rate > 3 ; Then I added multiple conditions. I got movies with rental rate greater than $3 and replacement cost less than $20. SELECT * FROM film WHERE rental_rate > 3 AND replacement_cost < 20 ; Next, I used OR condition retrieved movies that are either rated 'PG' or have a rental rate of $0.99. SELECT * FROM film WHERE rating = 'PG' OR rental_rate = 0 . 99 ; I also worked with limit and sorting. I showed the first 10 movies sorted by highest rental rate. SELECT * FROM film ORDER BY rental_rate DESC LIMIT 10 ; Then I used offset to skip rows. I skipped the first 5 movies and fetched the next 3 in ascending order. SELECT * FROM film ORDER BY rental_rate ASC LIMIT 3 OFFSET 5 ; I retrieved movies with rental duration between 3 and 7 days. SELECT * FROM film WHERE rental_duration BETWEEN 3 AND 7 ; I retrieved movies with rental duration more than 7 days. SELECT * FROM film WHERE ren

Continue reading on Dev.to Tutorial

Opens in a new tab

Read Full Article
8 views

Related Articles