where条件获取日期在两列family no和date

时间:2014-05-23 06:03:08

标签: java mysql jdbc

public class UserSearchDAO {


public ArrayList searchRecords(UserDTO udto) throws SQLException{

    DriverManager.registerDriver(new com.mysql.jdbc.Driver());
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/msdb","root","root");
    udto.getDate();
    }
    //elseif(udto.getDate()!=null && !udto.getDate().equals("")){
        //query = query+ "where date="+udto.getDate();

    System.out.println(query);
    Statement stmt = con.createStatement();
    ResultSet rs = stmt.executeQuery(query);
    ArrayList list = new ArrayList();




}

//这是获取familyno和date字段中记录的DAO层。你能帮我解决一下如何编写正确的查询。我是新数据库。

query = query +" familyno =" + udto.getFamilyno(),udto.getDate();

1 个答案:

答案 0 :(得分:-1)

一般格式,

query =select * from  table_name where table_col1="+getvalue1()+" && table_col2="+getvalue2()+";

为了你的数据库,

query="select * from  userVO where familyno="+udto.getFamilyno()+" && date="+udto.getDate()+";";