求sql模糊查询语句
来源:百度知道 编辑:UC知道 时间:2024/05/21 14:04:09
sql server数据库
public ArrayList selectStudent(String name){
ArrayList list=new ArrayList();
try{
db.getConnection();
ResultSet rs=db.Query("select * from Student where username like '%%'");
while(rs.next()){
list.add(new Student(rs.getInt(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5),rs.getString(6)));
}
}catch(Exception e){
e.printStackTrace();
}finally{
db.close();
}
return list;
}
这个方法带一个参数 不知道怎么把这个参数的值传到‘%%’中间 。。。
晕那个是值耶
按照你的那样 不成了查询name了。。呵呵
public ArrayList selectStudent(String name){
ArrayList list=new ArrayList();
try{
db.getConnection();
ResultSet rs=db.Query("select * from Student where username like '%%'");
while(rs.next()){
list.add(new Student(rs.getInt(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5),rs.getString(6)));
}
}catch(Exception e){
e.printStackTrace();
}finally{
db.close();
}
return list;
}
这个方法带一个参数 不知道怎么把这个参数的值传到‘%%’中间 。。。
晕那个是值耶
按照你的那样 不成了查询name了。。呵呵
//java
public ArrayList selectStudent(String name){
ArrayList list=new ArrayList();
try{
db.getConnection();
ResultSet rs=db.Query("select * from Student where username like '%"+name+"%'");
while(rs.next()){
list.add(new Student(rs.getInt(1),rs.getString(2),rs.getString(3),rs.getString(4),rs.getString(5),rs.getString(6)));
}
}catch(Exception e){
e.printStackTrace();
}finally{
db.close();
}
return list;
}
db.Query(@"select * from Student where username like '%"+name+"%'");
是c#么
string strCmd="select * from Student where username like '%"+name+"%'";
ResultSet rs=db.Query(strCmd);
嘿嘿,抱歉