子查询返回多于一行
more than one row returned by a subquery
我正在编写查询以在 table 中插入值。
它给我一个错误。
我的查询是:
INSERT INTO res_partner(
name,
company_id,
create_date,
street,
city,
display_name,
zip,
supplier,
ref,
is_company,
customer,
street2,
employee,
write_date,
active,
write_uid,
lang,
create_uid,
notify_email)
VALUES(
(SELECT shipping_address_name FROM temp_unicom),
1,
LOCALTIMESTAMP,
(SELECT shipping_address_line_1 FROM temp_unicom;),
(SELECT shipping_address_city FROM temp_unicom),
(SELECT shipping_address_name FROM temp_unicom),
(SELECT shipping_address_pincode FROM temp_unicom),
FALSE,
(Select sale_order_item_code FROM temp_unicom),
FALSE,
TRUE,
(SELECT shipping_address_line_2 FROM temp_unicom),
FALSE,
LOCALTIMESTAMP,
TRUE,
1,
'en_US',
1,
'always');
错误:
ERROR: more than one row returned by a subquery used as an expression
********** 错误 **********
ERROR: more than one row returned by a subquery used as an expression
SQL state: 21000
我知道每个 select 子查询 returns 多行,但我不知道如何修复错误。
我的 temp_unicom
table 中大约有 15,000 行,我正在尝试将数据从 temp_unicom
插入到 res_partner
。
您的代码是 insert ... select
语句的不正确语法。如果你想从 temp_unicom
table 中插入很多行,你应该重写你的查询如下
Insert into res_partner
(name,company_id,create_date,street,city,display_name,zip,supplier,ref,is_company,customer,street2,employee,write_date,active,write_uid,lang,create_uid,notify_email)
Select shipping_address_name,1, LOCALTIMESTAMP, shipping_address_name,
shipping_address_line_1,shipping_address_city,
shipping_address_name,shipping_address_pincode,sale_order_item_code,FALSE,
shipping_address_line_2,FALSE, LOCALTIMESTAMP, TRUE,1,'en_US',1,'always'
from temp_unicom
我正在编写查询以在 table 中插入值。 它给我一个错误。
我的查询是:
INSERT INTO res_partner(
name,
company_id,
create_date,
street,
city,
display_name,
zip,
supplier,
ref,
is_company,
customer,
street2,
employee,
write_date,
active,
write_uid,
lang,
create_uid,
notify_email)
VALUES(
(SELECT shipping_address_name FROM temp_unicom),
1,
LOCALTIMESTAMP,
(SELECT shipping_address_line_1 FROM temp_unicom;),
(SELECT shipping_address_city FROM temp_unicom),
(SELECT shipping_address_name FROM temp_unicom),
(SELECT shipping_address_pincode FROM temp_unicom),
FALSE,
(Select sale_order_item_code FROM temp_unicom),
FALSE,
TRUE,
(SELECT shipping_address_line_2 FROM temp_unicom),
FALSE,
LOCALTIMESTAMP,
TRUE,
1,
'en_US',
1,
'always');
错误:
ERROR: more than one row returned by a subquery used as an expression
********** 错误 **********
ERROR: more than one row returned by a subquery used as an expression
SQL state: 21000
我知道每个 select 子查询 returns 多行,但我不知道如何修复错误。
我的 temp_unicom
table 中大约有 15,000 行,我正在尝试将数据从 temp_unicom
插入到 res_partner
。
您的代码是 insert ... select
语句的不正确语法。如果你想从 temp_unicom
table 中插入很多行,你应该重写你的查询如下
Insert into res_partner
(name,company_id,create_date,street,city,display_name,zip,supplier,ref,is_company,customer,street2,employee,write_date,active,write_uid,lang,create_uid,notify_email)
Select shipping_address_name,1, LOCALTIMESTAMP, shipping_address_name,
shipping_address_line_1,shipping_address_city,
shipping_address_name,shipping_address_pincode,sale_order_item_code,FALSE,
shipping_address_line_2,FALSE, LOCALTIMESTAMP, TRUE,1,'en_US',1,'always'
from temp_unicom