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

  • 相关阅读:
    二叉树线索化。。。
    如何通过指针访问虚函数表,并且调用里面的方法
    进程间通信IPC
    什么时候该用assert
    高并发服务端分布式系统设计概要(上)
    C语言读写文件
    Linux 与 BSD 有什么不同?
    extern "C" 使用
    C语言字符数组的定义与初始化
    Linux守护进程
  • 原文地址:https://www.cnblogs.com/tuosang/p/2989286.html
Copyright © 2020-2023  润新知