Hi! Could we please enable some services and cookies to improve your experience and our website?

SQLize | PHPize | SQLtest

Online Sandbox for SQL and PHP: Write, Run, Test, and Share SQL Queries and PHP Code

A A A
Login    Share code      Blog   FAQ
Copy Format Clear
-- Session 1 (8th June, 2025) -- select * from film; -- title, rental_rate, length, rating -- select title, release_year, rental_rate, length, rating from film -- where rating = 'PG' or rating = 'G'; -- where rating in ('g', 'pg', 'pg-13'); -- where rating in ('g', 'r') and length > 100; -- where rating not in ('g', 'r') and length > 100; -- select title, release_year, rental_rate, length, rating from film -- -- where rating = 'G'; -- -- where rental_rate = 2.99; -- where rental_rate = 2.99 and rating = 'G'; -- select rating from film; -- select distinct rating from film -- order by rating; -- select title, length from film -- -- order by length; -- -- order by length desc; -- order by 2; -- Wildcard: -- % : means any number of characters. -- _ : one character -- select title, release_year, rental_rate, length, rating from film -- where title = 'S%'; THIS WILL NOT WORK... -- where title like 'S%'; -- where title like '%S'; -- where title like '%ea%'; -- where title like '%s_a'; -- select * from film -- limit 5; -- select title, release_year, rental_rate, length, rating from film -- select rating, count(title) from film -- group by rating; -- select rating, count(title) as total_movies from film -- group by rating -- order by 2; -- order by 2 desc; -- Recap of Session 1: -- select * from film -- where length <100 and rating in("g", "pg") -- limit 15; -- select title from film -- where title like "The%" -- select title, rating from film -- select rating, count(title) as num_movies from film -- group by rating -- order by 2 -- (Assending Order) -- order by 2 desc -- select rating, count(title) as num_movies from film -- group by rating -- having num_movies > 200 -- order by 2 desc -- select distinct rating from film -- *Creating CTE (Temporary Table)* -- with cte_g as ( -- select title, rating, length from film -- where rating = 'G' and length < 100) -- select * from cte_g -- where title like 'B%' select title, rating, length from (select title, rating, length from film where rating = 'G' and length < 100) temp where length > 80

Stuck with a problem? Got Error? Ask AI support!

Copy Clear