[英]Mysql stored procedure where clause
Ok let me try this again. 好吧,让我再试一次。
query("CALL getemployee('$eml')"); query(“CALL getemployee('$ eml')”); $result = $sql->fetch_array();
$ result = $ sql-> fetch_array(); ?> This is my stored procedure:
这是我的存储过程:
Delimiter //
Create procedure getemployee(in eml varchar(50))
Begin
Select * from employees where email = eml;
End//
Delimiter ;
The error i get from browser: "Fatal error: Call to a member function fetch_array() on a non-object ...". 我从浏览器得到的错误:“致命错误:在非对象上调用成员函数fetch_array()......”。
I use phpmyadmin version 3.2.4 and the mysql client version: 5.1.41 我使用phpmyadmin版本3.2.4和mysql客户端版本:5.1.41
Your CREATE PROCEDURE
statement appears to be invalid. 您的
CREATE PROCEDURE
语句似乎无效。
You need to give a name to your procedure, and to the parameter that you are passing. 您需要为您的过程以及您传递的参数指定名称。 Therefore you may want to try something like the following example:
因此,您可能想尝试类似以下示例:
DELIMITER //
CREATE PROCEDURE procName (IN eml varchar(50))
BEGIN
SELECT * FROM employees WHERE email = eml;
END//
DELIMITER ;
The eml
variable you use is not defined. 您使用的
eml
变量未定义。 Should not it be as following: 不应该如下:
Create procedure getemployee (in eml varchar(50))
CREATE PROCEDURE get_customers(IN inCustomerIdList VARCHAR(100))
BEGIN
SELECT first_name, last_name, email FROM tbl_customers
WHERE customer_id IN (inCustomerIdList);
END$$
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.