mysql报错1172该怎样解决_MySQL错误1172-结果包含多个行

bd96500e110b49cbb3cd949968f18be7.png

I'm getting this error from MySQL when running a query inside a stored procedure:

Error Code: 1172

Result consisted of more than one row

I understand the error: I'm doing a SELECT (...) INTO (var list), and thus the query is required to return a single row. When I use LIMIT 1 or SELECT DISTINCT, the error goes away.

However: when I run the original query manually (without LIMIT or DISTINCT), it does return a single row. So I'm suspecting I may have bumped into a MySQL bug. Does anyone know what could be happening?

EDIT

I'm posting the SQL as requested. Everything that starts with an underscore is a variable declared earlier inside the procedure. When I test it, I'm replacing _cd_pai_vc with the ID for the record that is causing the problem.

SELECT a.valor, IFNULL(p.valor, 0), fn_cd2alias(ra.cd_registro), fn_cd2alias(IFNULL(p.valor,0))

INTO _valor, _cd_pai_vc, _alias_verbete, _alias_pai

FROM dados_registros ra

INNER JOIN dados_varchar255 a

ON a.cd_registro = ra.cd_registro

AND a.fl_excluido = 0

AND a.alias = 'vc-verbetes-termo'

LEFT OUTER JOIN dados_registros rp

INNER JOIN dados_int p

ON p.cd_registro = rp.cd_registro

AND p.fl_excluido = 0

AND p.alias = 'vc-remissoes-termo referenciado'

INNER JOIN dados_int pt

ON pt.cd_registro = rp.cd_registro

AND pt.fl_excluido = 0

AND pt.alias = 'vc-remissoes-tipo remissao'

AND fn_cd2alias(pt.valor) = 'hierarquica'

ON ra.cd_registro = rp.cd_entidade

AND rp.fl_excluido = 0

AND fn_cd2alias(rp.cd_modulo) = 'vc-remissoes'

WHERE ra.cd_registro = _cd_pai_vc

AND ra.fl_excluido = 0;

解决方案

I had the similiar issue and when I put table alias it worked like a charm.

SELECT t.tax_amount,t.tax_percentage FROM nepse_tax t

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值