CREATE or REPLACE VIEW myView AS
SELECT t2.film_id, t2.no_actors AS n_actor, COALESCE(t1.no_copies,0) AS n_inventory FROM
(SELECT film_id, count(film_id) AS no_copies FROM inventory GROUP BY film_id) AS t1 RIGHT OUTER JOIN
(SELECT film_id, count(actor_id)
AS no_actors FROM film_actor GROUP BY film_id) AS t2
ON t2.film_id=t1.film_id;
The above query gives the error:
ERROR 1349 (HY000): View's SELECT contains a subquery in the FROM clause
How do we write nested views for the above query in one single query ? Please help. Thanks in advance.