Php 存储过程错误:子查询返回超过1行

Php 存储过程错误:子查询返回超过1行,php,mysql,stored-procedures,mysql-error-1242,Php,Mysql,Stored Procedures,Mysql Error 1242,我试图创建一个存储过程,但给了我一个错误:子查询为下面的查询返回超过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(

我试图创建一个存储过程,但给了我一个错误:子查询为下面的查询返回超过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
); 

在子查询的
WHERE
子句中添加更多术语,将其减少到一个记录,或者在同一记录中添加
LIMIT
子句。

在子查询中添加LIMIT子句。

我认为您根本不需要子查询。您可以在更新查询中直接引用多个表:

问题已解决。。。 对于子查询(SELECT语句),导致此错误的专利uid缺少别名。 输入表名作为别名后,它在存储过程中开始正常工作


感谢大家的帮助…

Limit并没有解决问题,因为在php脚本或mysql查询浏览器中运行同一查询时,会通过更新多行来提供所需的输出,但当添加到存储过程中时,会出现上述错误。您是否在更新或选择中设置了限制?我怀疑是后者。你能引用确切的错误和创建SP时使用的确切SQL吗?我在select query中添加了一个条件。使用update怎么可能???