复制代码 代码如下:
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;