我试图在日期中添加一个整数,但是我收到以下错误:
#1064 - 您的SQL语法出错;检查与您的MySQL服务器版本相对应的手册,以便使用接近'(wp.OrderDate,INTERVAL WPProduct.Duration DAY)AS ExpiryDate FROM wp'第6行
SELECT
wp.customers_id,
wp.OrderDate,
wp.products_id,
WPProduct.Duration,
DATE_ADD (wp.OrderDate, INTERVAL WPProduct.Duration DAY) AS ExpiryDate
FROM wp
INNER JOIN WPProduct ON WPProduct.products_id = wp.products_id
WHERE wp.customers_id = 2
答案 0 :(得分:2)
在DATE_ADD后删除空格:
SELECT
wp.customers_id,
wp.OrderDate,
wp.products_id,
WPProduct.Duration,
DATE_ADD(wp.OrderDate, INTERVAL WPProduct.Duration DAY) AS ExpiryDate
FROM wp
INNER JOIN WPProduct ON WPProduct.products_id = wp.products_id
WHERE wp.customers_id = 2