MYsqlL IF status = 0语句从不返回row,如果我删除IF语句,它将起作用 [英] MYsqlL IF status=0 statement never returns row , it works if i remove IF statment

查看:76
本文介绍了MYsqlL IF status = 0语句从不返回row,如果我删除IF语句,它将起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人:
我是MySql的新手
请帮助我在该IF语句中弄错的地方,即当我给出最后一个paramenter(Status)= 0时,该IF语句未运行.
在查询编辑器中运行相同查询时,它们独立运行良好.
还告诉我一些真实的MYSQL环境esp.运行功能和过程.
谢谢
纳兹什

Dear All:
i m a newbie in MySql
kindly help me where i m mistaken in that IF Statement that its not running when i give last paramenter(Status)=0.
Same queries working fine independently when i run them in query editor.
also tell me some authentice MYSQL envoirnment esp. to run Functions and procedure.
thanks
Nazish

BEGIN
IF   (Status =0)  THEN
SELECT * , st.SRTech_Description AS RStatus, st.SRTechStatus_Name AS RSInitials
FROM requestdeployment rd, sr_TechStatus st, SupportRequest SR
LEFT JOIN Locations L ON SR.SR_SupportLId = L.Id
WHERE Scc_id
IN ( Con )
AND sr.SR_id = rd.requestid
AND SRTechStatus_ID
IN (
SELECT STATUS FROM requestdeployment
WHERE RequestId = SR.SR_Id
)
and rd.active!=1
and rd.deployedby=DPID
and rd.status=st.srtechstatus_id;



ELSE

SELECT * , st.SRTech_Description AS RStatus, st.SRTechStatus_Name AS RSInitials
FROM requestdeployment rd, sr_TechStatus st, SupportRequest SR
LEFT JOIN Locations L ON SR.SR_SupportLId = L.Id
WHERE Scc_id
IN ( Con )
AND sr.SR_id = rd.requestid
AND SRTechStatus_ID
IN (

SELECT STATUS FROM requestdeployment
WHERE RequestId = SR.SR_Id
)
and rd.active!=1
and rd.deployedby=DPID
and rd.status=st.srtechstatus_id
and st.SrtechStatus_ID=Status;
END IF;

END

推荐答案

我觉得您可能在传递参数错误,并且结果Select永远不会设置为0,因此第一个查询永远不会运行.

您需要返回到原始代码,检查如何传递Select的值.还要检查存储过程(如果是上述内容),则如何定义Select.
I get the feeling you are maybe passing in the parameter wrong, and as a result Select is never being set to 0 so the first query never runs.

You need to go back to your original code, check how you are passing in the value of Select. Also check in the Stored Procedure (If that is what is above), how Select is being defined.


这篇关于MYsqlL IF status = 0语句从不返回row,如果我删除IF语句,它将起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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