student表
id    stuName   teamId
1       张三       1
2       王五       1
3       李四       1team表
teamId   teamName
1         三剑客teamId是外键,帮忙写一条hql语句,要求根据一个学生的id(已知)得到该学生所在队伍的所有成员的stuName

解决方案 »

  1.   

    select stuName from student where teamId in(    SELECT s.teamId FROM  student as s , team as t where id=? and t.teamId=s.teamId)
      

  2.   

    多表联合没用过HQL 只用过SQL
      

  3.   

    from Student student  where student.team.teamId in(select student.team.teamId from student,Team team where student.team.teamId=team.teamId and student.id=1)这样搞定了,不过还不知道怎么获取id    ~0~
      

  4.   

    String hql = "from Student student  where student.team.teamId in(select student.team.teamId from student,Team team where student.team.teamId=team.teamId and student.id=id)"   结贴 谢谢大家