#1172-结果由多个行组成

发布于 2025-01-22 19:27:49 字数 493 浏览 3 评论 0原文

我正在接收#1172-结果由多个行组成错误,每当我尝试在MySQL中的表中插入一些值时,我都会搜索此错误,并发现触发器给出了问题(它具有在其中选择语句):

以下是我的触发代码

DELIMITER $
CREATE OR REPLACE TRIGGER book
AFTER INSERT ON books
FOR EACH ROW
BEGIN
DECLARE slot_id INT;
SELECT slotno INTO slot_id FROM books WHERE slotno = new.slotno;
UPDATE slots SET slot_status = 0 WHERE slotno = slot_id;
END;
$

,当我第一次尝试时,该代码正常工作,但是现在几周后,它给出了此错误 请告诉我如何解决它,或者如何在没有触发器的情况下实现同一件事,

如何选择语句返回多个行?

I am receiving #1172 - Result consisted of more than one row error whenever I try to insert some values in my table in MYSQL, I searched for this error and found out that the trigger is giving the problem (it has SELECT INTO statement in it)

Following is my trigger code

DELIMITER $
CREATE OR REPLACE TRIGGER book
AFTER INSERT ON books
FOR EACH ROW
BEGIN
DECLARE slot_id INT;
SELECT slotno INTO slot_id FROM books WHERE slotno = new.slotno;
UPDATE slots SET slot_status = 0 WHERE slotno = slot_id;
END;
$

this code was working fine when I tried it for the first time but now after some weeks it is giving this error
pls tell me how can I resolve it or how can I implement the same thing without triggers

How is this SELECT INTO statement returning more than one row?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文