存储过程正在删除所有行 [英] Stored Procedure is removing all rows

查看:82
本文介绍了存储过程正在删除所有行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下过程:(请确保直接从MySQL Workbench提取DDL代码)

I have this procedure: (DDL code extracted directly from MySQL Workbench just to make sure)

DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `removerContacto`(nome VARCHAR(250),id INT)
BEGIN
DELETE FROM Contactos WHERE Nome = nome AND UsersID = id;
END




我这样称呼:




and I call it this way:

mysql_query("CALL removerContacto(''".$_GET[''nome'']."'',''".$_GET[''uid'']."'')");



问题是删除所有行而不是删除所有行(仅针对该WHERE子句).如果我尝试



The problem is removing all rows instead only one (there''s only for that WHERE clause). If I try

mysql_query("DELETE FROM Contactos WHERE Nome =''".$_GET[''nome'']."'' AND UsersID=".$_GET[''uid'']."");



或直接在工作台上



or directly at workbench

DELETE FROM Contactos WHERE Nome = ''someone'' AND UsersID = 1;



它可以正常工作.我在做什么错?



It works correctly. What am I doing wrong?

推荐答案

创建 DEFINER =`root` @`localhost` 程序`removerContacto`(nome VARCHAR ( 250 ), id INT ) 开始 删除 FROM Contactos 位置 Nome = nome AND UsersID = id; END
CREATE DEFINER=`root`@`localhost` PROCEDURE `removerContacto`(nome VARCHAR(250),id INT) BEGIN DELETE FROM Contactos WHERE Nome = nome AND UsersID = id; END




我这样称呼:




and I call it this way:

mysql_query("CALL removerContacto(''".


_GET[''nome'']."'',''".
_GET[''nome'']."'',''".


_GET[''uid'']."'')");
_GET[''uid'']."'')");



问题是删除所有行而不是删除所有行(仅针对该WHERE子句).如果我尝试



The problem is removing all rows instead only one (there''s only for that WHERE clause). If I try

mysql_query("DELETE FROM Contactos WHERE Nome =''".


这篇关于存储过程正在删除所有行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆