Creando vistas en mysql

Categorías, películas y actores:

create view pelistotal as
select category_id, category.name nombrecategoria,
film_id,title,actor_id,
first_name,last_name 
from category join film_category using (category_id)
join film using (film_id)
join film_actor using (film_id)
join actor using (actor_id)

La usamos como una tabla normal:

select name,count(actor_id) total 
from pelistotal 
group by category_id
select * from actor 
where actor_id not in (
SELECT actor_id FROM pelistotal where name='action');

Como hacer una consulta del tipo actores que no han trabajado en películas de acción si usar subconsultas. Primero creamos la vista en positivo:

create view actores_accion as 
select actor_id,first_name,last_name from 
category join film_category using (category_id)
join film using (film_id)
join film_actor using (film_id)
join actor using (actor_id) 
where name='action'

Y después hacemos un left join y buscamos los nulos:

SELECT * FROM actor left join actores_accion using(actor_id)
where actores_accion.first_name is null

Ejemplos Create view

create view peliculas_pais as
select country, count(rental_id) total
from country join city using (country_id)
join address using(city_id)
join customer using(address_id)
join rental using(customer_id)
group by country_id
CREATE VIEW peliculas_categoria AS
select name, count(film_id) total
from category join film_category using (category_id)
group by category_id