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 )";
                }
            }

  • 相关阅读:
    gobject对象不宜作为动态加载的插件
    用内存管理器的钩子函数跟踪内存泄漏
    DBUS与多线程
    broncho小组放假半天为中国奥运加油
    多进程DirectFB用X11显示的死锁问题
    佛诞节快乐
    R语言中substr函数,字符串截取函数
    R语言中while循环
    R语言中求分位数
    R语言中利用sapply函数提取列表中元素
  • 原文地址:https://www.cnblogs.com/tuosang/p/2989286.html
Copyright © 2011-2022 走看看