欢迎来到福编程网,本站提供各种互联网专业知识!
您的位置:网站首页 > 数据库 > Mysql

MySQL 视图 第1349号错误解决方法

发布时间:2008-03-13 作者: 来源:转载
把下面SQL里的SELECT单独执行,没有问题,但是用来CREATEVIEW就报错了.

复制代码 代码如下:
CREATEORREPLACEVIEWBLOG_V_ADMIN
(ID,NICKNAME,SEX,EMAIL,PHONE,QQ,MSN,HTTP,REGISTER_TIME,
IP,LAST_LOGIN_IP,LOGIN_TIME)
AS
SELECT
A.ID,A.NICKNAME,A.SEX,A.EMAIL,A.PHONE,A.QQ,A.MSN,A.HTTP,A.REGISTER_TIME,
B.IPASLAST_LOGIN_IP,B.LOGIN_TIMEASLAST_LOGIN_TIME
FROM
BLOG_ADMINALEFTJOIN
BLOG_ADMIN_LOGIN_TRACKBONB.ADMIN=A.IDLEFTJOIN
(SELECTADMIN,MAX(LOGIN_TIME)ASLOGIN_TIMEFROMBLOG_ADMIN_LOGIN_TRACKGROUPBYADMIN)CONB.ADMIN=C.ADMIN;
ERROR1349(HY000):View'sSELECTcontainsasubqueryintheFROMclause
这是BUG吗?见:http://bugs.mysql.com/bug.php?id=16757


木有办法,我只好这样改了:

复制代码 代码如下:
CREATEORREPLACEVIEWBLOG_V_ADMIN
(ID,NICKNAME,SEX,EMAIL,PHONE,QQ,MSN,HTTP,REGISTER_TIME,
LOGIN_TIME,LAST_LOGIN_IP)
AS
SELECT
A.ID,A.NICKNAME,A.SEX,A.EMAIL,A.PHONE,A.QQ,A.MSN,A.HTTP,A.REGISTER_TIME,
(SELECTLOGIN_TIMEFROMBLOG_ADMIN_LOGIN_TRACKWHEREADMIN=A.IDORDERBYLOGIN_TIMEDESCLIMIT1)ASLAST_LOGIN_TIME,
(SELECTINET_NTOA(IP)FROMBLOG_ADMIN_LOGIN_TRACKWHEREADMIN=A.IDORDERBYLOGIN_TIMEDESCLIMIT1)ASLAST_LOGIN_IP
FROM
BLOG_ADMINA;

相关推荐