电商常用符号有哪些字体 电商标题有哪些
1 2024-03-09 10:36:50
大家好,今日小深来为大家解答以上的问题。sql批量查3000个id,批量查询sql很多人还不知道,现在让我们一起来看看吧!
1、先创建一个方法create FUNCTION dbo.FunSplitStringToAraay(@vchString varchar(1000))RETURNS @tabArray table(string varchar(100))ASBEGINDECLARE @intStart intDECLARE @intLocation intDECLARE @vchSubstring varchar(100)SELECT @intStart =1SELECT @intLocation = CHARINDEX(',',@vchString,@intStart)WHILE (@intLocation <> 0 )BEGINSELECT @vchSubstring=SUBSTRING(@vchString,@intStart,@intLocation-@intStart)INSERT INTO @tabArray(string) SELECT @vchSubstringSELECT @intStart = @intLocation +1SELECT @intLocation = CHARINDEX(',',@vchString,@intStart)ENDRETURNENDinsert into #aselect dbo.FunSplitStringToAraay (传入 的id) idselect from table where id in (select id from #a)建一个数组,把所有id放入数组中,然后在string s="";foreach(int i in shuzu){s+=i+",";}s=s.subString(s.Length-1);string sql="select from 表名 where id in ("+s+")";用查询语句拼接select from 表名 where id="+id1+" or id="+id2+"........Private Sub InitMcode()If v_resondept <> "" ThenDim resondeptlist() As String = v_resondept.Split(",")For Each str As String In resondeptlist…………NextEnd IfEnd Subvb 的 参考下select from 表名 where id in (id1,id2,id3.....)。
本文到这结束,希望上面文章对大家有所帮助。