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;

            }

  • 相关阅读:
    在线服务之性能测试工具科普
    在线服务之socket编程科普
    Hadoop发展历史简介
    TCP/IP协议知识科普
    操作系统之内存管理科普
    操作系统之进程管理科普
    开源PaaS产品介绍
    并行计算知识科普
    IaaS层市场科普
    WCF服务开发与调用的完整示例
  • 原文地址:https://www.cnblogs.com/yk25com/p/2672345.html
Copyright © 2011-2022 走看看