如何更改表中数据的值? [英] How do I change the value of data in table?

查看:104
本文介绍了如何更改表中数据的值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我将aantal更改为0时,由于某种原因它会变回5。

有人知道为什么吗?

i想要为aantal填充一个数字然后乘以prijs。



everytime when i change aantal to 0 it changes back to 5 for some reason.
does someone know why?
i want to fill a number for aantal and then multiply it with "prijs".

bierid aantal  prijs
1	5	2
2	0	2
NULL	NULL	NULL

CREATE TABLE [dbo].[Bier] (
    [BierId]             INT IDENTITY (1, 1) NOT NULL,
    [Aantal_consumpties] INT NULL ,
    [Prijs]              INT NOT NULL,
    PRIMARY KEY CLUSTERED ([BierId] ASC)





我尝试过:



选择总和(Aantal_consumpties * Prijs)AS prijsbier FROM Bier;



What I have tried:

"select sum(Aantal_consumpties * Prijs) AS prijsbier FROM Bier";

推荐答案

你不做改变价值



You do not change the value by doing

select sum(Aantal_consumpties * Prijs) AS prijsbier FROM Bier





您需要的是更新:





What you need is an UPDATE:

UPDATE Bier SET Aantal_consumpties = 5;
select sum(Aantal_consumpties * Prijs) AS prijsbier FROM Bier;


你真的需要在这里度过一段时间 [click] [ ^ ]。这是一个相当友好的环境,您可以边做边学。



只要学习如何进行基本的SQL查询,就会更容易,特别是从长远来看。
You really need to spend some time here [click][^]. This is a rather friendly environment where you can learn-by-doing.

It's much easier, especially in the long run, to just learn how to do basic SQL queries.


这篇关于如何更改表中数据的值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆