• T SQL 模糊多条件查询实现[,分隔]


    T - SQL 模糊多条件查询实现[,分隔]  

     if (Distribution_Address !="")
            {

                if (Distribution_Address.Trim().Length == 0)
                {
                    strSql = " 1=1";
                }
               else
                {
                    int start =0;//设定替换前的字符串长度
                    int end = 0;//设定替换后的字符串长度
                    string temptxt = Distribution_Address.Trim();
                    do
                    {
                        start = temptxt.Length;
                        temptxt = temptxt.Replace(",", ",").Replace("  ", " ");
                        end = temptxt.Length;
                    } while (start != end);//如果替换前后长度变化,则继续替换
                    string[] tempStr = temptxt.Split(',');
                    strSql += "and (";
                    foreach (string temp in tempStr)
                    {
                        if (strSql.Trim().Length != 0) 
                        strSql += String.Format("(C_Address like '%{0}%')", temp);
                        strSql += "or";
                    }
                    strSql += " 1=2 )";
                }
            }

  • 相关阅读:
    2021 3 11 结队博客
    第一周 2021.03.07
    2021 3 5 知识点总结
    2021 3 3 每日总结
    2021 3 2 新学期的第一篇博客
    十天冲刺09
    二阶段之四
    安卓开发之实现手机验证码登录
    安卓布局(三)
    安卓布局(二)
  • 原文地址:https://www.cnblogs.com/tuosang/p/2989286.html
Copyright © 2020-2023  润新知