开发者

ERROR 1349 (HY000): View's SELECT contains a subquery in the FROM clause

I do not want to create two separate views.

create view fg_voted as (
  select * 
    from (select f1.foto, coun开发者_开发技巧t(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);

How can I write it in a single query to create view?


How about this instead?

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
 );
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜