inclassactivity101823
an anonymous user
·
MySQL
CREATE TABLE Movie (
ID INT AUTO_INCREMENT,
Title VARCHAR(100),
Rating CHAR(5) CHECK (Rating IN ('G', 'PG', 'PG-13', 'R')),
ReleaseDate DATE,
PRIMARY KEY (ID)
);
INSERT INTO Movie (Title, Rating, ReleaseDate) VALUES
('Casablanca', 'PG', '1943-01-23'),
('The Dark Knight', 'PG-13', '2008-07-18'),
('Hidden Figures', 'PG', '2017-01-06'),
('Toy Story', 'G', '1995-11-22'),
('Rocky', 'PG', '1976-11-21'),
('Crazy Rich Asians', 'PG-13', '2018-08-15');
-- SELECT *
-- FROM Movie;
-- 1.Modify the SELECT statement to select the title and release date of PG-13 movies.
SELECT Title, ReleaseDate
FROM Movie
WHERE Rating = 'PG-13';
-- 2.Modify the SELECT statement to select the title and release date of movies released after January 1, 2008.
SELECT Title, ReleaseDate
FROM Movie
WHERE ReleaseDate > '2008-01-01';
-- 3.Modify the SELECT statement to select the title and release date of PG-13 movies that are released after January 1, 2008.(4.1.9)
SELECT Title, ReleaseDate
FROM Movie
WHERE Rating = 'PG-13' AND ReleaseDate > '2008-01-01';
-- 4.Modify the SELECT statement to select the title and release date of PG-13 movies OR movies that are released after January 1, 2008.
SELECT Title, ReleaseDate
FROM Movie
WHERE Rating = 'PG-13' OR ReleaseDate > '2008-01-01';
-- 5.Modify the SELECT statement to select the title and release date of movies rated PG, PG-13, or R. (IN Operator)
SELECT Title, ReleaseDate
FROM Movie
WHERE Rating IN ('PG', 'PG-13', 'R');
-- 6.Modify the SELECT statement to select the title and release date of movies that are released Between January 1, 2008 and January 1, 2018.(Between Operator)
SELECT Title, ReleaseDate
FROM Movie
WHERE ReleaseDate BETWEEN '2008-01-01' AND '2018-01-01';
-- 7.Modify the SELECT statement to select movies with the word 'star' somewhere in the title. (4.2.4 LIKE operator)
SELECT Title, ReleaseDate
FROM Movie
WHERE Title LIKE '%star%';
-- 8.Modify the SELECT statement to select movies with titles starting with the letter 'T'. (LIKE operator)
SELECT Title, ReleaseDate
FROM Movie
WHERE Title LIKE 'T%';
-- 9.Modify the SELECT statement to select movies that has the letter 'o' as the second letter in their titles. (LIKE operator)
SELECT Title, ReleaseDate
FROM Movie
WHERE Title LIKE '_o%';
Output
Embed on website
To embed this program on your website, copy the following code and paste it into your website's HTML:
Comments
This comment belongs to a banned user and is only visible to admins.
This comment belongs to a deleted user and is only visible to admins.