NutzCN Logo
问答 mysql创建视图问题
发布于 1591天前 作者 qq_412bd180 1240 次浏览 复制 上一个帖子 下一个帖子
标签:
CREATE VIEW v_employee AS (
SELECT * , taskcount = (SELECT COUNT(id) FROM t_task AS t WHERE t.eid = e.id) FROM t_employee AS e;
)

在mysql里创建视图失败 , sql语句应该怎么改

4 回复

在nutz文档使用视图一节中的例子

CREATE VIEW v_employee AS (
SELECT * , taskcount = (SELECT COUNT(id) FROM test_task AS t WHERE t.eid = e.id) FROM test_employee AS e
)

[SQL]CREATE VIEW v_employee AS (
SELECT * , taskcount = (SELECT COUNT(id) FROM test_task AS t WHERE t.eid = e.id) FROM test_employee AS e
)

[Err] 1054 - Unknown column 'taskcount' in 'field list'

那是pgsql的写法,你用自己的建表语句就好啦,何必纠结这个例子

添加回复
请先登陆
回到顶部