【发布时间】:2010-12-03 07:13:30
【问题描述】:
我正在尝试创建一个存储过程,但给了我一个错误:子查询为以下查询返回超过 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
);
【问题讨论】:
-
您能否引用确切的错误以及您尝试创建 SP 的确切 SQL?
标签: php mysql stored-procedures mysql-error-1242