MYSQL存储过程 新手求指教!!!

LOVE-漂泊 2014-09-03 10:45:10
create procedure sp3(in p1 int , in p2 int , in p3 VARCHAR,out p int)
begin

if p2=0 & p3='' then
select count(b_id) from lottery_bet_old,lottery_strategy where b_strategyid=s_sid and b_haoma<>'[]' and b_userid=p1;
elseif p2=0 & p3!='' then
select count(b_id) from lottery_bet_old,lottery_strategy where b_strategyid=s_sid and b_haoma<>'[]' and b_userid=p1 and CONCAT(b_periods,b_betCount,b_winningCount,b_amountCount,s_stype,s_sname,b_status) LIKE '%"+p3+"%';
elseif p2!=0 & p3='' then
select count(b_id) from lottery_bet_old,lottery_strategy where b_strategyid=s_sid and b_haoma<>'[]' and b_userid=p1 and lt_typeid=p2;
elseif p2!=0 & p3!='' then
select count(b_id) from lottery_bet_old,lottery_strategy where b_strategyid=s_sid and b_haoma<>'[]' and b_userid=p1 and lt_typeid=p2 and CONCAT(b_periods,b_betCount,b_winningCount,b_amountCount,s_stype,s_sname,b_status) LIKE '%"+p3+"%';
end if;
select count;

end

这个存储过程哪里错了??
...全文
255 21 打赏 收藏 转发到动态 举报
写回复
用AI写文章
21 条回复
切换为时间正序
请发表友善的回复…
发表回复
Defonds 2014-09-03
  • 打赏
  • 举报
回复
不是吧,mysql 区好冷清
LOVE-漂泊 2014-09-03
  • 打赏
  • 举报
回复
引用 7 楼 defonds 的回复:
手头没有 mysql 环境。帮你移到 mysql 版块来了,让专业人士看看吧
没一个人回答的、、、、、、、
LOVE-漂泊 2014-09-03
  • 打赏
  • 举报
回复
没人吗????
LOVE-漂泊 2014-09-03
  • 打赏
  • 举报
回复
引用 7 楼 defonds 的回复:
手头没有 mysql 环境。帮你移到 mysql 版块来了,让专业人士看看吧
哦哦 谢谢版主了 搞半天找不到问题 估计是低级问题 、、、
Defonds 2014-09-03
  • 打赏
  • 举报
回复
手头没有 mysql 环境。帮你移到 mysql 版块来了,让专业人士看看吧
LOVE-漂泊 2014-09-03
  • 打赏
  • 举报
回复
引用 5 楼 defonds 的回复:
if (p2=0) AND (p3='')
改成这样还是那个错误
Defonds 2014-09-03
  • 打赏
  • 举报
回复
if (p2=0) AND (p3='')
LOVE-漂泊 2014-09-03
  • 打赏
  • 举报
回复
引用 3 楼 defonds 的回复:
if (p2=0 & p3='')
if (p' at line 1 加了报这个错误、、、
Defonds 2014-09-03
  • 打赏
  • 举报
回复
if (p2=0 & p3='')
LOVE-漂泊 2014-09-03
  • 打赏
  • 举报
回复
引用 1 楼 defonds 的回复:
1)你运行报的啥错? 2)lottery_bet_old,lottery_strategy 的表结构是啥
[SQL] create procedure sp3(in p1 int , in p2 int , in p3 VARCHAR,out p int) begin if p2=0 & p3='' then select count(b_id) from lottery_bet_old,lottery_strategy where b_strategyid=s_sid and b_haoma<>'[]' and b_userid=p1; elseif p2=0 & p3!='' then select count(b_id) from lottery_bet_old,lottery_strategy where b_strategyid=s_sid and b_haoma<>'[]' and b_userid=p1 and CONCAT(b_periods,b_betCount,b_winningCount,b_amountCount,s_stype,s_sname,b_status) LIKE '%"+p3+"%'; elseif p2!=0 & p3='' then select count(b_id) from lottery_bet_old,lottery_strategy where b_strategyid=s_sid and b_haoma<>'[]' and b_userid=p1 and lt_typeid=p2; elseif p2!=0 & p3!='' then select count(b_id) from lottery_bet_old,lottery_strategy where b_strategyid=s_sid and b_haoma<>'[]' and b_userid=p1 and lt_typeid=p2 and CONCAT(b_periods,b_betCount,b_winningCount,b_amountCount,s_stype,s_sname,b_status) LIKE '%"+p3+"%'; end if; select count; end [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'out p int) begin if p2' at line 1 就普通的表
Defonds 2014-09-03
  • 打赏
  • 举报
回复
1)你运行报的啥错? 2)lottery_bet_old,lottery_strategy 的表结构是啥
c_sdn_shang_bu_qi 2014-09-03
  • 打赏
  • 举报
回复
我想问下select count(b_id) from你这个查询出来放结果到哪?
tjzero_sapce 2014-09-03
  • 打赏
  • 举报
回复
我觉得也是没有指定长度的问题
LOVE-漂泊 2014-09-03
  • 打赏
  • 举报
回复
引用 18 楼 huasuoworld 的回复:
你给p3指定下长度试试in p3 VARCHAR(100);
好了谢谢! 再麻烦下 我那个like 那里写 能接受参数吗??
huasuoworld 2014-09-03
  • 打赏
  • 举报
回复
你给p3指定下长度试试in p3 VARCHAR(100);
LOVE-漂泊 2014-09-03
  • 打赏
  • 举报
回复
引用 16 楼 huasuoworld 的回复:
语法错误 create procedure ... is begin ... end;

create or replace procedure sp3(in p1 int , in p2 int , in p3 VARCHAR,out p int) is
 begin

 if p2=0 and p3='' then
select count(b_id) from lottery_bet_old,lottery_strategy where b_strategyid=s_sid and b_haoma<>'[]' and b_userid=p1;
 else if p2=0 and p3!='' then
select count(b_id) from lottery_bet_old,lottery_strategy where b_strategyid=s_sid and b_haoma<>'[]' and b_userid=p1 and CONCAT(b_periods,b_betCount,b_winningCount,b_amountCount,s_stype,s_sname,b_status) LIKE '%"+p3+"%';

 else if p2!=0 and p3='' then
    select count(b_id) from lottery_bet_old,lottery_strategy where b_strategyid=s_sid and b_haoma<>'[]' and b_userid=p1 and lt_typeid=p2;
 else if p2!=0 and p3!='' then
    select count(b_id) from lottery_bet_old,lottery_strategy where b_strategyid=s_sid and b_haoma<>'[]' and b_userid=p1 and lt_typeid=p2 and CONCAT(b_periods,b_betCount,b_winningCount,b_amountCount,s_stype,s_sname,b_status) LIKE '%"+p3+"%';
 end if;
select count;

 end
MYSQL不需要is的吧
huasuoworld 2014-09-03
  • 打赏
  • 举报
回复
语法错误 create procedure ... is begin ... end;

create or replace procedure sp3(in p1 int , in p2 int , in p3 VARCHAR,out p int) is
 begin

 if p2=0 and p3='' then
select count(b_id) from lottery_bet_old,lottery_strategy where b_strategyid=s_sid and b_haoma<>'[]' and b_userid=p1;
 else if p2=0 and p3!='' then
select count(b_id) from lottery_bet_old,lottery_strategy where b_strategyid=s_sid and b_haoma<>'[]' and b_userid=p1 and CONCAT(b_periods,b_betCount,b_winningCount,b_amountCount,s_stype,s_sname,b_status) LIKE '%"+p3+"%';

 else if p2!=0 and p3='' then
    select count(b_id) from lottery_bet_old,lottery_strategy where b_strategyid=s_sid and b_haoma<>'[]' and b_userid=p1 and lt_typeid=p2;
 else if p2!=0 and p3!='' then
    select count(b_id) from lottery_bet_old,lottery_strategy where b_strategyid=s_sid and b_haoma<>'[]' and b_userid=p1 and lt_typeid=p2 and CONCAT(b_periods,b_betCount,b_winningCount,b_amountCount,s_stype,s_sname,b_status) LIKE '%"+p3+"%';
 end if;
select count;

 end
huasuoworld 2014-09-03
  • 打赏
  • 举报
回复
create or replace procedure sp3(in p1 int , in p2 int , in p3 VARCHAR,out p int) is
begin

if p2=0 and p3='' then
select count(b_id) from lottery_bet_old,lottery_strategy where b_strategyid=s_sid and b_haoma<>'[]' and b_userid=p1;
else if p2=0 and p3!='' then
select count(b_id) from lottery_bet_old,lottery_strategy where b_strategyid=s_sid and b_haoma<>'[]' and b_userid=p1 and CONCAT(b_periods,b_betCount,b_winningCount,b_amountCount,s_stype,s_sname,b_status) LIKE '%"+p3+"%';

else if p2!=0 and p3='' then
select count(b_id) from lottery_bet_old,lottery_strategy where b_strategyid=s_sid and b_haoma<>'[]' and b_userid=p1 and lt_typeid=p2;
else if p2!=0 and p3!='' then
select count(b_id) from lottery_bet_old,lottery_strategy where b_strategyid=s_sid and b_haoma<>'[]' and b_userid=p1 and lt_typeid=p2 and CONCAT(b_periods,b_betCount,b_winningCount,b_amountCount,s_stype,s_sname,b_status) LIKE '%"+p3+"%';
end if;
select count;

end
LOVE-漂泊 2014-09-03
  • 打赏
  • 举报
回复
引用 13 楼 defonds 的回复:
我不是 mysql 的版主,移不回去啊 你点击“管理菜单”里的“移动”看看自己能移回去吗
移回去了 谢谢啊!
Defonds 2014-09-03
  • 打赏
  • 举报
回复
我不是 mysql 的版主,移不回去啊 你点击“管理菜单”里的“移动”看看自己能移回去吗
加载更多回复(1)

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧