Home  >  Q&A  >  body text

MySQL创建视图不可以包含子查询吗

创建视图时,SQL语句不可以包含子查询的吗???
例如:

CREATE VIEW view_name 
AS
SELECT [...]
FROM 
(
    SELECT [...]
    FROM [...]
    WHERE [...]
)
WHERE [...]

执行上述SQL语句会报错,假如要创建如上视图,有没有什么好的解决方案呢???

今天无意中遇到上述问题,麻烦各位给个建议,蟹蟹,^_^...

大家讲道理大家讲道理2742 days ago665

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-04-17 16:27:10

    A common subquery is written as follows

      select ename,deptno,sal
      from emp
      where deptno=(select deptno from dept where loc='NEW YORK');
      
      
    

    Is yours an inline graph subquery? Can you post the wrong statement? Below is an example

      
      SELECT ename,job,sal
      FROM (SELECT ename,job,sal FROM EMP ORDER BY sal);

    reply
    0
  • 迷茫

    迷茫2017-04-17 16:27:10

    It’s not that it’s impossible, but some methods and features cannot be used. You’d better post the SQL and let people see it

    reply
    0
  • Cancelreply