此查询在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' );
错误是
信息表创建如下所示
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 ));
答案 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 |