我无法在此处插入日期。我的 table 是:
CREATE TABLE salary
(
emp_id int NOT NULL,
basic int,
net_salary double,
salary_date date,
FOREIGN KEY(emp_id) REFERENCES employee(emp_id)
)
当我给予时:
INSERT INTO `salary`(`emp_id`, `basic`, `net_salary`, `salary_date`)
VALUES (121,5000,,20190-06-21)
它显示一条错误消息:
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '20190-06-21)' at line 1
最佳答案
double 据类型不能为空。您可以为 net_salary
列放置零值或空值。
此外,20190-06-21
不是有效日期,可能是 2019-06-21
。年份 20190
有 5 位数字。
工作查询将是:
INSERT INTO `salary`(`emp_id`, `basic`, `net_salary`, `salary_date`)
VALUES (121, 5000, 0, '2019-06-21')
或
INSERT INTO `salary`(`emp_id`, `basic`, `net_salary`, `salary_date`)
VALUES (121, 5000, null, '2019-06-21')
关于mysql - 为什么 mysql 中的日期会出现此错误消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56751986/