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 行的值计数不匹配”。为什么?

4

2 回答 2

1

看起来您的表格tblcustomermachine比 1 列多。

就像 Simone 回答的那样,将您的插入更新为INSERT INTO tblcustomermachine(col_1) SELECT ...

您可以在 期间跳过列名INSERT,但是SELECT需要返回与表中相同数量的列。

于 2011-02-08T12:56:42.183 回答
0

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
   );
于 2011-02-08T11:36:51.407 回答