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列以上あるようです。

シモーネが答えたように、あなたの挿入物をに更新してください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 に答える