我们希望将此示例数据库中的日期更新为更新的日期。将每个季度代码增加5年,以便19964看起来像20014.通过在表格中显示数据来验证您的结果。我正在使用mySQL Oracle CommandLine客户端,并想知道如何将所有访问日期记录更新5年。
interview table
+---------------+--------------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+---------------+--------------+------+-----+---------+-------+
| interviewdate | date | YES | | NULL | |
+---------------+--------------+------+-----+---------+-------+
interviewdate column
+---------------+
| interviewdate |
+---------------+
| 1995-06-01 |
| 1995-06-01 |
| 1995-06-30 |
| 1995-06-30 |
| 1995-07-01 |
| 1995-08-01 |
| 1995-08-01 |
| 1995-08-02 |
| 1995-12-01 |
| 1995-12-02 |
| 1995-12-04 |
| 1996-01-21 |
| 1996-02-01 |
| 1996-02-02 |
| 1996-07-01 |
| 1996-07-01 |
| 1996-08-01 |
| 1996-08-08 |
| 1996-08-11 |
| 1997-01-01 |
| 1997-01-01 |
| 1997-01-31 |
| 1997-02-01 |
| 1997-03-24 |
| 1997-03-31 |
| 1997-04-20 |
| 1997-04-22 |
| 1997-05-01 |
+---------------+
28 rows in set (0.00 sec)
我试过这样的事情:
UPDATE interview
SET qtrcode = DATEADD(year, 5, qtrcode);
ERROR 1305 (42000): FUNCTION jobs.DATEADD does not exist
答案 0 :(得分:4)
这应该有效:
update interview
set interviewdate = date_add(interviewdate, interval 5 year);