插入和子选 [英] Insert and subselect
本文介绍了插入和子选的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
INSERT INTO S654321.PERSON
(PNR,FIRSTNAME,LASTNAME)
VALUES
SELECT 32,FIRSTNAME,LASTNAME
FROM S654321。 CUSTOMER
WHERE CUSTNR ='C002'
返回sqlcode -104和sqlstate 42601.你看到错误?
select语句本身是正确的。
解决方案
错误是当您插入记录时,请使用select,或指定值。你不这么做这是确定
插入表
(field1)
值
(value1)
如下:
插入表
(field1)
从某个地方选择不同的价值1
所以选择一个方法。
INSERT INTO S654321.PERSON
(PNR, FIRSTNAME, LASTNAME)
VALUES
SELECT 32, FIRSTNAME, LASTNAME
FROM S654321.CUSTOMER
WHERE CUSTNR = 'C002'
Returns sqlcode -104 and sqlstate 42601. Do you see the error? The select statement itself is correct.
解决方案
The error is that when you insert records you either use a select, or you specify the values. You don't do both. This is ok
insert into table
(field1)
values
(value1)
as is this:
insert into table
(field1)
select distinct value1
from somewhere
So pick a method.
这篇关于插入和子选的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文