以数据库里查询出来的字段继续查询怎么做呀??
如题:
String url = "jdbc:informix-sqli://26.100.210.2:5000/security:INFORMIXSERVER=clafonline;NEWCODESET=GBK,8859-1,819 ";
String user= "informix ";
String password= "informix ";
String tmp= "select * from sec_person where workcode= '在岗 'and personcode= '保卫管理人员 ' "+ "order by birth desc ";
conn= DriverManager.getConnection(url,user,password);
stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
rs=stmt.executeQuery(tmp);
rs.first();下面是我胡乱写的,我的算法是,刚才不是取了第一个记录了么,然后以第一个记录集的字段ID为条件,再次查询,然后得到结果集,并作出判断--workcode不等于“解聘”“退休”,数据有效,否则就无效。
想问的就是以ID再次查询同一数据表怎么写呀,请详细点
//String id=rs.getString( "id ");
//conn.close();
//String tmp2= "select * from sec_person where id = ' "+id+ " ' ";
//conn= DriverManager.getConnection(url,user,password);
//stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
//rs=stmt.executeQuery(tmp2);
//String workcode=rs.getString( "workcode ");
------解决方案--------------------嵌套查询看看
select workcode where id in( select id from sec_person where workcode= '在岗 'and personcode= '保卫管理人员 ' ")
可以得到workcode,然后再判断