select stuId ,teacherId from T_Table
比如上述的SQL语句中,查询出来的数据是stuId和teacherId 。userId对应的那条数据在 T_SYS_PARAM 中,
teacherId也在T_SYS_PARAM 表中,但是它们对应的是不同的记录,采用LEFT JOIN T_SYS_PARAM 的方法并不奏效。为了查询出学生的名字和老师的名字,必须分别查询。
select t.stuId , t.teacherId , (select p.stuName from T_SYS_PARAM p where p.id= t.stuId) stuName , (select p.tecName from T_SYS_PARAM p where p.id= t.teacherId) tecName from T_Table t
所以说,怪不得项目里面有那么多像 " ( ) "这样的查询