CREATE VIEW USER_VIEW AS
(
SELECT USERS.ID ID,
USERS.EMAIL EMAIL,
USERS.PASSWORD PASSWORD,
ADDDATE(USERS.START_DATE, INTERVAL USERS.DURATION MONTH) "EXPIRY_DATE",
DATEDIFF(EXPIRY_DATE, NOW()) "STATUS");
Mysql正在生成此错误信息:
答案 0 :(得分:0)
我会把它写成:
CREATE VIEW USER_VIEW AS
SELECT u.ID, u.EMAIL, u.PASSWORD,
DATE_ADD(u.START_DATE, INTERVAL u.DURATION MONTH) as EXPIRY_DATE,
DATEDIFF(DATE_ADD(u.START_DATE, INTERVAL u.DURATION MONTH), CURDATE()) as status
FROM users u;
注意:
FROM
条款。这是您查询中的重大错误。EXPIRY_DATE
status
指的是前一行中的表达式。这是不允许的。你必须重复这个表达。u.id
时,列名称将被称为id
。NOW()
更改为CURDATE()
。