【问题标题】:ERROR 1349 (HY000): View's SELECT contains a subquery in the FROM clauseERROR 1349 (HY000): View 的 SELECT 在 FROM 子句中包含子查询
【发布时间】:2011-03-24 08:59:08
【问题描述】:

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

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

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

【问题讨论】:

    标签: mysql sql view mysql-error-1349


    【解决方案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
     );
    

    【讨论】:

      猜你喜欢
      • 2014-06-21
      • 1970-01-01
      • 1970-01-01
      • 2020-02-08
      • 2012-01-15
      • 2014-07-09
      • 1970-01-01
      相关资源
      最近更新 更多