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;

            }

  • 相关阅读:
    Linux下使用ps命令来查看Oracle相关的进程
    虚继承、虚基类
    C++/C小知识点(2)
    C++中的运行中动态类型识别RTTI
    什么应该放在头文件?何为外连接?
    Placement new、operator new、new operator 完全释疑
    二叉搜索树
    Linux C编程学习资料,学习过程
    独立对象(非附属对象)大小
    编程珠玑第一章、第二章
  • 原文地址:https://www.cnblogs.com/yk25com/p/2672345.html
Copyright © 2011-2022 走看看