我有一个包含 3 列(
COMPONENTS
、Sno
、Component
)的表 Quantity
,其中我最初写的是 Sno
和 Component
列,我想使用填充“数量”列某些表达式(例如:((d1+d2)*d3)
)涉及另一个表中的变量SHEET(d1 int,d2 int ,d3 int,d4 int ,d5 int,d6 int)
。
这里我需要根据 COMPONENTS 表(components.sno)中 Sno 列中的值将值写入数量列。
我曾经将表达式值保留在“x”中并尝试插入到组件中,如下所示:
insert into components(Quantity) values(x)
where components.sno='y'; [Y is inetger starting from 0 to 70]
但是上面的查询在
where
处显示错误
请建议我最好的 SQL 查询来实现这一点! 预先感谢..!
除非是
INSERT
,否则您不能使用 WHERE
子句执行 WHERE NOT EXISTS
,所以只需执行:
INSERT INTO components(Quantity) VALUES(x)
也许你需要做
UPDATE
UPDATE components SET Quantity=x WHERE components.sno='y';
在
IF
之前使用 insert
语句,并且不要使用 where
子句:
If <your condition>
Begin <your statement>
End