原生sql 多表查询_JAVA_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > JAVA > 原生sql 多表查询

原生sql 多表查询

 2011/1/7 8:29:41  haohao-xuexi02  http://haohao-xuexi02.javaeye.com  我要评论(0)
  • 摘要:Sessionsession=Sessionsession=super.getSession();session.flush();Connectioncon=session.connection();Stringuid="";StringBuffersql=newStringBuffer();sql.append("selecta.user_Idfromuser_infoasa");//user用户表sql.append(leftjoin(selectb
  • 标签:SQL 多表查询
   Session session =Session session = super.getSession();
   session.flush();
   Connection con = session.connection(); 

     String uid="";
     StringBuffer sql = new StringBuffer();
        sql.append("select a.user_Id from user_info as a");//user用户表
     sql.append( left join  (select b.userid from B_info as b where b.userid="+uid+"  
      and ( b.bdate=     (select max(bdate) from b_info where  userid=b.userid)) )) as binfo on a.user_id=binfo.userid

      Statement stmt = (Statement) con.createStatement();
      ResultSet rs = stmt.executeQuery(sql.toString());
     while(rs.next())  
        {  
      uid=rs.getString(1);
        
     }

     return uid;
 }

 

?

上一篇: hadoop的运行原理 下一篇: 没有下一篇了!
发表评论
用户名: 匿名