zoukankan      html  css  js  c++  java
  • SQL 多条件查询

    private void doQuery() 

    Bool hasWhere = false; 
    StringBuilder sql = new StringBuilder(" SELECT * FROM T_Employee"); 
    if(工号复选框选中) 

    hasWhere = appendWhereIfNeed(sql, hasWhere);
    sql.appendLine("FNumber BETWEEN '"+工号文本框1内容+"' AND '"+工号文本框2内容+"'"); 

    if(姓名复选框选中) 

    hasWhere = appendWhereIfNeed(sql, hasWhere); 
    sql.appendLine("FName LIKE '%"+姓名文本框内容+"%'"); 

    if(年龄复选框选中) 

    hasWhere = appendWhereIfNeed(sql, hasWhere); 
    sql.appendLine("FAge BETWEEN "+年龄文本框1内容+" AND "+年龄文本框2内容); 

    executeSQL(sql); 

    private Bool appendWhereIfNeed(StringBuilder sql,Bool hasWhere) 

    if(hasWhere==false) 

    sql. appendLine("WHERE"); 

    else 

    sql. appendLine("AND"); 

    }

    摘自《程序员的SQL金典》。

  • 相关阅读:
    安装solr
    Linux下安装mysql
    SQL JOIN
    SQL之TCL
    SQL之DCL
    SQL之DML
    SQL之DDL
    Mysql 常用查询语句
    Java-Poi 读取excel 数据
    工作中的第一份LoadRunner脚本
  • 原文地址:https://www.cnblogs.com/boentouch/p/9951955.html
Copyright © 2011-2022 走看看