如何列出其会员资格到期续会的会员名称和地址?

时间:2017-04-13 18:05:47

标签: sql oracle

我收到此错误消息'缺少右括号'使用以下sql查询:

SELECT G_MEMBERSHIP.MEMBER_ID, DATE_ADD(G_MEMBERSHIP.RENEWAL_DATE,INTERVAL 1 YEAR)  WHERE G_MEMBERSHIP.RENEWAL_DATE > CURDATE()
FROM G_MEMBERSHIP
INNER JOIN G_MEMBER
ON G_MEMBERSHIP.MEMBER_ID = G_MEMBER.MEMBER_ID

2 个答案:

答案 0 :(得分:1)

WHEREJOIN

之后
SELECT G_MEMBERSHIP.MEMBER_ID, DATE_ADD(G_MEMBERSHIP.RENEWAL_DATE,INTERVAL 1 YEAR)  
FROM G_MEMBERSHIP
INNER JOIN G_MEMBER
  ON G_MEMBERSHIP.MEMBER_ID = G_MEMBER.MEMBER_ID
WHERE G_MEMBERSHIP.RENEWAL_DATE > CURDATE()

答案 1 :(得分:0)

SELECT G_MEMBERSHIP.MEMBER_ID,add_months(G_MEMBERSHIP.RENEWAL_DATE,12)  
FROM G_MEMBERSHIP
INNER JOIN G_MEMBER
ON G_MEMBERSHIP.MEMBER_ID = G_MEMBER.MEMBER_ID
WHERE G_MEMBERSHIP.RENEWAL_DATE > current_date

P.S。

+ INTERVAL '1'存在风险

e.g。

select date '2012-02-29' + INTERVAL '1' YEAR from dual;
  

ORA-01839:日期对指定的月份无效

select add_months (date '2012-02-29',12) from dual
  

2013-02-28 00:00:00