mysql - 为什么 mysql 中的日期会出现此错误消息?

标签 mysql

我无法在此处插入日期。我的 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/

相关文章:

mysql - 为什么 count(column) 和 count(*) 返回相同的输出,即使记录中有 NULL 值?

php - 在自定义管理页面上提交表单 (Wordpress)

MySQL通过多个外键进行查询

MySQL 组数据,每组和订单有 2 个结果

mysql - 无法在 cent 0s 6.10 上启动 Mysql 5.7

php - If/else 语句仅适用于 1 个变量值

mysql - 如何在 MySQL 中获取 shell 的输出?

java - JDBC模板更新查询错误

mysql - 将 phpmyadmin 数据库中的 http 替换为 https

Mysql根据多案例取记录