insert into tblcustomermachine
(
select * from
((select vch_CustomerID from tblcustomer where tblcustomer.vch_CustomerID='Cust00001' )
union all
(select Rate from tblmachine)) as t );
该表包含 18 个列,此结果集还包含 18 行,但它显示“列数与第 1 行的值计数不匹配”。为什么?
insert into tblcustomermachine
(
select * from
((select vch_CustomerID from tblcustomer where tblcustomer.vch_CustomerID='Cust00001' )
union all
(select Rate from tblmachine)) as t );
该表包含 18 个列,此结果集还包含 18 行,但它显示“列数与第 1 行的值计数不匹配”。为什么?
看起来您的表格tblcustomermachine
比 1 列多。
就像 Simone 回答的那样,将您的插入更新为INSERT INTO tblcustomermachine(col_1) SELECT ...
您可以在 期间跳过列名INSERT
,但是SELECT
需要返回与表中相同数量的列。
AFAIK,您必须声明字段名称:
insert into tblcustomermachine (col_1, col_2, col_3, ... col_18) (
select t.field1, t.field2, t.field3, ... t.field18 from (
(select vch_CustomerID from tblcustomer where tblcustomer.vch_CustomerID='Cust00001')
union all (select Rate from tblmachine))
as t
);