zoukankan      html  css  js  c++  java
  • 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 )";
                }
            }

  • 相关阅读:
    这仅仅是一份工作
    和老总之间的对话
    假设满足怎样的条件,就不去编程
    那都是别人的架构
    程序员狂想曲
    学点经济学知识(三)
    一起来看 HTML 5.2 中新的原生元素 <dialog>
    动态配置页面 之 组件系统
    初识JavaScript EventLoop
    webpack+vue-cli+ElementUI+vue-resource 前端开发
  • 原文地址:https://www.cnblogs.com/tuosang/p/2989286.html
Copyright © 2011-2022 走看看