错误1349(HY000):视图的SELECT包含FROM子句中的子查询

时间:2011-03-24 08:59:08

标签: mysql sql view mysql-error-1349

我不想创建两个单独的视图。

create view fg_voted as (
  select * 
    from (select f1.foto, count(f1.vote) stars,f1.vote, f1.voted 
            from fg_foto_bewertung f1 
           where f1.vote >= 3 group by f1.foto, f1.vote) vi_foto 
   where stars > 3);

如何在单个查询中编写它以创建视图?

1 个答案:

答案 0 :(得分:1)

相反怎么样?

create view fg_voted as (

  SELECT f1.foto, 
         count(f1.vote) stars,
         f1.vote, 
         f1.voted 
  FROM   fg_foto_bewertung f1 
  WHERE  f1.vote >= 3 
  GROUP BY f1.foto, 
           f1.vote, 
           f1.voted 
  HAVING count(f1.vote) > 3
 );