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;

            }

  • 相关阅读:
    Windows服务的删除与添加
    综合布线施工规范与工艺
    电表产品型号代表什么意义?
    网线接线顺序
    电机绝缘电阻的测量方法
    实用电工口诀
    电工需熟知应用口诀-巧用低压验电笔
    各种工业以太网比较(EtherCAT,EtherNet/IP,ProfiNet,Modbus-TCP,Powerlink)
    C# 开启线程的几种方式
    C# 内置的类型转换方法
  • 原文地址:https://www.cnblogs.com/yk25com/p/2672345.html
Copyright © 2011-2022 走看看