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

  • 相关阅读:
    Lombok 安装、入门
    Centos 6.5中使用yum安装jdk
    Mysql规范和使用注意点(转)
    Java编码规范
    windows2016重新配置sid
    Postman POST接口请求无法获取数据
    微信修改密码
    SQL事务
    .net时间格式化
    SQL查询列是否有重复值
  • 原文地址:https://www.cnblogs.com/tuosang/p/2989286.html
Copyright © 2011-2022 走看看