亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

Beheben Sie den Fehler, dass das MySQL-Ergebnis mehrere Zeilen enth?lt
P粉068174996
P粉068174996 2024-04-04 16:42:59
0
1
613

Wenn ich diese Abfrage ausführe, erhalte ich die Fehlermeldung ?Fehlercode: 1172. Das Ergebnis enth?lt mehrere Zeilen“

CREATE DEFINER=`root`@`localhost` PROCEDURE `un_follow`(
  user_been_following_id int,
  user_following_id int
)
BEGIN
    declare id int;
    select following_id into id from user_following
        where user_been_following_id = user_been_following_id
        and  user_following_id =  user_following_id; 
        
    delete from user_following 
    where following_id = id;
END
Ist es hilfreich, dass

id der Prim?rschlüssel der folgenden Tabelle ist?

P粉068174996
P粉068174996

Antworte allen(1)
P粉322319601

您的局部變量與表列同名。 這樣,您就永遠不會將局部變量與列進行比較,而始終將局部變量與局部變量本身進行比較。

您的查詢需要恰好返回一行來提供 id 變量

select following_id into id from user_following
    where user_been_following_id = user_been_following_id
    and  user_following_id =  user_following_id;

user_been_following_id 和 user_following_id 在所有實例中都被解釋為局部變量,因此翻譯如下

select following_id into id from user_following
    where 1 = 1
    and  1 = 1;

其中返回 user_following 的所有行。要解決此問題,請重命名您的局部變量,例如

CREATE DEFINER=`root`@`localhost` PROCEDURE `un_follow`(
  local_user_been_following_id int,
  local_user_following_id int
)
BEGIN
    declare id int;
    select following_id into id from user_following
        where user_been_following_id = local_user_been_following_id
        and  user_following_id =  local_user_following_id; 
    
    delete from user_following 
    where following_id = id;
END

(假設表 user_following 上沒有名為 local_user_been_following_id 或 local_user_following_id 的列)

另請參閱此處: https://dev.mysql.com/doc/ refman/8.0/en/local-variable-scope.html

Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage