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

杀马特。学长 韩版系。学妹 提交于 2020-01-03 05:46:32

问题


I do not want to create two separate views.

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

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


回答1:


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


来源:https://stackoverflow.com/questions/5416809/error-1349-hy000-views-select-contains-a-subquery-in-the-from-clause

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!