如何在空值列中插入/更新数据?

时间:2017-10-10 06:48:45

标签: c# sql insert

我有一个名为{ "Version": "2012-10-17", "Statement": [ { "Sid": "Stmt1493183261000", "Effect": "Allow", "Action": [ "dynamodb:BatchGetItem", "dynamodb:BatchWriteItem", "dynamodb:DeleteItem", "dynamodb:DescribeStream", "dynamodb:DescribeTable", "dynamodb:GetItem", "dynamodb:GetRecords", "dynamodb:GetShardIterator", "dynamodb:ListStreams", "dynamodb:ListTables", "dynamodb:PutItem", "dynamodb:Query", "dynamodb:Scan", "dynamodb:UpdateItem", "dynamodb:UpdateTable" ], "Resource": [ "arn:aws:dynamodb:us-east-1:*:table/foo", "arn:aws:dynamodb:us-east-1:*:table/bar", "arn:aws:dynamodb:us-east-1:*:table/bar/index/dayKey-captureTime-index" ] } ] } 的表,它有5列:dtr id student_id time_intime_out

我在我的项目中做的是让用户输入一个ID号,然后程序会扫描它,如果ID号在数据库中。如果它在数据库中,则ID号的第一个输入将在date列中插入数据。在相同ID号的第二个输入上,将在time_in列中插入数据。

这就是我想要发生的事情:

time_out

1 个答案:

答案 0 :(得分:0)

//更新' time_in'在time_out'中有一个值并添加时间您可以使用的栏目:

//Update dtr set student_id=@student_id, time_in=@time_in, time_out=@time_out, date=@date where ID = @id;
Update dtr set time_in=@time_in where ID = @id;

插入新行:

Insert into dtr (student_id, time_in,time_out,date) values(@student_id, @time_in, @time_out, @date);