zoukankan      html  css  js  c++  java
  • 多条件Sql语句

    public static string doQuery()
            {
                bool hasWhere = false;
                StringBuilder sql = new StringBuilder("select * from table");
                if (true)
                {
                    hasWhere = appendWhereIfNeed(sql, hasWhere);
                    sql.AppendLine("FNumber between ' 工号文本框1内容 ' and '工号文本框2内容 '");
                }
                if (true)
                {
                    hasWhere = appendWhereIfNeed(sql, hasWhere);
                    sql.AppendLine("FNumber2 between ' 工号文本框1内容 ' and '工号文本框2内容 '");
                }
                if (true)
                {
                    hasWhere = appendWhereIfNeed(sql, hasWhere);
                    sql.AppendLine("FNumber3 between ' 工号文本框1内容 ' and '工号文本框2内容 '");
                }
                return sql.ToString();
                 
            }

            private static bool appendWhereIfNeed(StringBuilder sql, bool hasWhere)
            {
                if (hasWhere == false)
                {
                    sql.AppendLine(" where ");
                    hasWhere = true;
                }
                else
                {
                    sql.AppendLine(" and ");

                }
                return hasWhere;

            }

  • 相关阅读:
    Java类的静态块の二
    Java类的静态块の一
    Eclipse优化工具Optimizer for Eclipse
    C#实现MD5WITHRSA签名
    Ubuntu 初始化Root账户密码
    shell连接本机虚拟机
    Nodejs的Express完成安装指导
    node.js之Windows 系统下设置Nodejs NPM全局路径
    Unicode, UTF-8, GBK, ASCII的区别
    BootstrapValidation一些tips
  • 原文地址:https://www.cnblogs.com/yk25com/p/2672345.html
Copyright © 2011-2022 走看看