我的表格COMPONENTS
包含3列(Sno
,Component
,Quantity
),其中我正在撰写Sno
和{{1}最初的列,我想使用某个表达式(例如Component
)来填充“数量”列,其中包含来自另一个表 ((d1+d2)*d3)
的变量。
这里我需要根据COMPONENTS表(components.sno)中的Sno列中的值将值写入数量列。
我曾经在'x'中保留表达式值并尝试插入COMPONENTS,如下所示:
SHEET(d1 int,d2 int ,d3 int,d4 int ,d5 int,d6 int)
但上述查询显示insert into components(Quantity) values(x)
where components.sno='y'; [Y is inetger starting from 0 to 70]
请建议我最好的SQL查询来实现这一目标! 在此先感谢..!
答案 0 :(得分:7)
除非是INSERT
,否则您无法WHERE
WHERE NOT EXISTS
子句,所以只需执行:
INSERT INTO components(Quantity) VALUES(x)
也许你需要做UPDATE
UPDATE components SET Quantity=x WHERE components.sno='y';
答案 1 :(得分:-1)
在IF
之前使用insert
声明,不要使用where
条款:
If <your condition>
Begin <your statement>
End