如何为以下查询实现存储过程 [英] How to implement a store procedure for the following query
问题描述
我正在查询以下内容,一次将获取多个数据,但是我不知道如何为此编写存储过程,这对任何人都可以帮忙吗
这是我的查询
I am having query as follows which will get multiple data at a time but i am not knowing how to write a store procedure for this can any one help me
This is my query
Select File_Data from tblachmaster WHERE Id IN (1,2,3, and so on);
从我的代码开始,我必须通过我想在存储过程中声明一个变量,并且必须按照我的需要执行
这是我的代码
<pre>string deleteSQL = "Select File_Data from tblachmaster WHERE Id IN (" + gvIDs.Substring(0, gvIDs.LastIndexOf(",")) + ")";</pre>
这不是像这样写,我必须使用store proc执行
As from my code i has to pass i would like to declare a variable in stored procedure and has to execute as per i needed
This is my code
<pre>string deleteSQL = "Select File_Data from tblachmaster WHERE Id IN (" + gvIDs.Substring(0, gvIDs.LastIndexOf(",")) + ")";</pre>
This instead of writing like this i have to use store proc to execute
推荐答案
我希望您知道如何在mysql中编写SP.
这是您查询的逻辑,请在SP中执行以下操作.
I hope you are aware of how to write SP in mysql .
Here is the logic for your query please do sandwitch this in SP.
SET @test = Select File_Data from tblachmaster WHERE Id IN (' + @ConditionVar + ')';
PREPARE stmt FROM @test;
EXECUTE stmt;
如果您需要更多帮助,请给我更多时间,我会给您确切的SP.
但是,请让我知道上述解决方案的结果.
If you need more help give me some more time I will give you exact SP.
But please let me know the result of above solution.
这篇关于如何为以下查询实现存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!