public List SearchAll(){
List l = new ArrayList()
EmployeeBean ea = null
ResultSet rs = null
PreparedStatement ps = null
Connection con = null
sql = "select * from Employee"
try {
con = BaseDAO.GetConnection()
ps = con.prepareStatement(sql)
rs = ps.executeQuery()
while (rs.next()) {
ea = new EmployeeBean()
ea.setId(rs.getInt(1))
ea.setDerpartId(rs.getInt(2))
ea.setName(rs.getString(3))
ea.setPassword(rs.getString(4))
l.add(ea)
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace()
}finally{
BaseDAO.close(rs, ps, con)
}
return l
}
如何查询oracle数据库一个表中的很多条记录是否有重复?重复的判断标准是指定为几个字段中只要有任意的一个字段中有重复就将重复的记录列出来。Select * From Table1 a
Where Exists (
Select * from Table1
where id=a.id
Group By ID
Having Count(*) > 1 //查出两条以上的记录
)
or:
Select * From Table1
Where id in (
Select id from Table1
Group By ID
Having Count(*) > 1 //查出两条以上的记录
)
or:
Select * From yourtable A
Where (Select count(*) From yourtable Where Field1=A.Field1)>1
or (Select count(*) From yourtable Where Field2=A.Field2)>1
or (Select count(*) From yourtable Where Field3=A.Field3)>1 ...
Order By A.Field1,Field2,Field3 ...
SELECT Field1,Field2 FROM TableName WHRER Field='Value'Field1,Field2就是你要获取的信息
还可以继续添加比如Field1,Field2,Field3,Field4
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)