我正在尝试创建一个存储过程,但出现了一个错误: Subquery为下面的查询返回超过1行。这可以使用游标来完成,但有没有其他方法可以直接在存储过程中运行这个查询,而不使用游标,因为有多个这种类型的查询,我需要将其添加到多个表的存储过程中。
查询:-
UPDATE ipcc_patent_ipc_class
SET assignee_type = (
SELECT IF(ipcc_patent_master.assignee_type='$ipcc_config_param[0]',$ipcc_config_value[0],IF(ipcc_patent_master.assignee_type='$ipcc_config_param[1]',$ipcc_config_value[1],null))
FROM ipcc_patent_master
WHERE ipcc_patent_ipc_class.patent_id = patent_uid);但此查询适用于多个字段:-
UPDATE ipcc_patent_ipc_class
SET geographies_id=(
SELECT ipcc_geographies.geographies_uid
FROM ipcc_patent_master,ipcc_geographies
WHERE ipcc_patent_master.geographies = ipcc_geographies.geographies
AND ipcc_patent_ipc_class.patent_id = ipcc_patent_master.patent_uid
),
jurisdictions_id =(
SELECT ipcc_jurisdictions.jurisdisctions_uid
FROM ipcc_patent_master,ipcc_jurisdictions
WHERE ipcc_patent_master.jurisdictions = ipcc_jurisdictions.jurisdictions
AND ipcc_patent_ipc_class.patent_id = ipcc_patent_master.patent_uid
),
country_code_id =(
SELECT ipcc_country_code.country_code_uid
FROM ipcc_patent_master,ipcc_country_code
WHERE ipcc_patent_master.country_code= ipcc_country_code.country_code
AND ipcc_patent_ipc_class.patent_id = ipcc_patent_master.patent_uid
); 发布于 2010-12-03 15:19:04
在子查询中添加Limit子句。
发布于 2010-12-03 15:17:00
向您的子查询的WHERE子句中添加更多的术语以将其减少到一条记录,或者向同一条记录中添加一个LIMIT子句。
发布于 2010-12-03 15:20:52
我认为这里根本不需要子查询。可以在UPDATE查询中直接引用多个表:
http://dev.mysql.com/doc/refman/5.0/en/update.html
https://stackoverflow.com/questions/4343277
复制相似问题