gpt4 book ai didi

MySQL 查询插入默认数据而不是输入数据

转载 作者:行者123 更新时间:2023-11-29 13:01:39 26 4
gpt4 key购买 nike

我目前正在为私有(private)住房贷款部门编写一个网络应用程序。在此应用程序中,贷款条款是在借款人、发起人和资金来源之间创建的,以便他们在申请贷款时可以选择最符合其需求的条款...

我使用的是 MySQL 5.4。该表具有三个外键(borrowerId、originatorId、fundingSourceId)。可以更新现有行,但我的插入命令不会插入其数据,而只会插入具有表默认值的新行。表格的格式如下...

id                  int(11)    NOTNULL,PRIMARY,AUTO_INCREMENT
borrowerId int(11) NOTNULL,DEFAULT 0
originatorId int(11) NOTNULL,DEFAULT 0
fundingSourceId int(11) NOTNULL,DEFAULT 0
originatorFee dec(10,2) NOTNULL
fundingSourceFee dec(10,2) NOTNULL
interestRate dec(5,3) NOTNULL
penaltyRate dec(5,3) NOTNULL
loanDuration int(11) NOTNULL,DEFAULT 0
minimumInterestDays int(11) NOTNULL,DEFAULT 0
disabled tinyint(1) NOTNULL,DEFAULT 0
createdAt datetime NOTNULL
updatedAt datetime NULL
deletedAt datetime NULL

这是我的插入命令,它生成一行全为零的行,而不是我输入的数据(包括创建于 0000-00-00 00:00:00)

INSERT INTO loanterms
(borrowerId,originatorId,originatorFee,fundingSourceId,fundingSourceFee,
interestRate,penaltyRate,loanDuration,minimumInterestDays,disabled,createdAt)
VALUES (borrowerId = 64, originatorId = 3, originatorFee = 300.00,
fundingSourceId = 11, fundingSourceFee = 300.00, interestRate = 15.00,
penaltyRate = 20.00, loanDuration = 6, minimumInterestDays = 30, disabled = 0,
createdAt = now())

编辑:以下查询生成一行,其中正确包含所有数据...我必须将 ID 自动递增字段插入到查询中。这是不是说明我的自增有问题呢?我该如何修复它?

INSERT INTO loanterms VALUES (124, 64, 3, 11, 300.00, 300.00, 15.00, 20.00, 6, 
30, 0, now(), NULL, NULL)

编辑2:谢谢大家指出我的愚蠢错误...抱歉,我花了几分钟才意识到这一点。这是一个午夜查询,我今天还没有喝咖啡......

最佳答案

MySQL:

更改:

INSERT INTO loanterms
(borrowerId,originatorId,originatorFee,fundingSourceId,fundingSourceFee,
interestRate,penaltyRate,loanDuration,minimumInterestDays,disabled,createdAt)
VALUES (borrowerId = 64, originatorId = 3, originatorFee = 300.00,
fundingSourceId = 11, fundingSourceFee = 300.00, interestRate = 15.00,
penaltyRate = 20.00, loanDuration = 6, minimumInterestDays = 30, disabled = 0,
createdAt = now())

:

INSERT INTO loanterms
set borrowerId = 64,
originatorId = 3,
originatorFee = 300.00,
fundingSourceId = 11,
fundingSourceFee = 300.00,
interestRate = 15.00,
penaltyRate = 20.00,
loanDuration = 6,
minimumInterestDays = 30,
disabled = 0,
createdAt = now();

关于MySQL 查询插入默认数据而不是输入数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23252555/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com