mysql maria DBServer查询

时间:2017-10-08 06:03:59

标签: mysql

此查询在mariaDB服务器中发出错误

insert into Information(First_name,Last_name,Father_name,Mother_name,Gender,DOB,Address,entry_made)
values('Yx','Vx','O','S','f','1994-09-13','P',(CURDATE()  )  AS 'DD' );

错误是

1064 - 您的SQL语法出错;检查与您的MariaDB服务器版本对应的手册,以便在第1行的“DD”附近使用正确的语法

信息表创建如下所示

create table information (First_name varchar(100) ,Last_name varchar(100) ,Father_name varchar(100) ,Mother_name varchar(100) ,Gender enum ('m','f'),DOB date  ,Address varchar(100) ,entry_made date not null ,primary key(First_name,Last_name ,Father_name,Mother_name,Gender,DOB,Address  ));

1 个答案:

答案 0 :(得分:1)

你只需要CURDATE()不需要别名或额外的括号:

insert into Information
      (First_name,Last_name,Father_name,Mother_name,Gender,DOB         ,Address,entry_made)
values('Yx'      ,'Vx'     ,'O'        ,'S'        ,'f'   ,'1994-09-13','P'    ,CURDATE())
;

CREATE TABLE Table1
    (`entry_made` datetime)
;

INSERT INTO Table1
    (`entry_made`)
VALUES
    ('2017-03-02 00:00:00'),
    (CURDATE()),
    (NOW())
;

<强>查询

select * from table1

|           entry_made |
|----------------------|
| 2017-03-02T00:00:00Z |
| 2017-10-08T00:00:00Z |
| 2017-10-08T07:07:06Z |