怎么写mysql存储过程,并用php调用它

2025-04-06 00:09:54
推荐回答(1个)
回答1:

mysql创建的存储,在mysql里执行就可以

create procedure pr_user_get(
p_user_id int -- 传入的参数

)
proc_start:begin
select b.*
from table1 as a,table2 as b
where a.userid = p_user_id

and a.username = b.username;

end proc_start

php调用
$sql = "call pr_user_get('$userid')";
$result = mysql_query($sql);
$row = mysql_fetch_array($result);

$row 就是了