表的连接查询

想要在展示用户数据(from identification)表的同时连接另一个表(department),并且获取对应院系的表名

解决方法:

修改sql语句的写法

通过identification里的d_id与department里d_id的链接名相等获取这个值去实现表之间的链接。详细写法见代码处

1 sql = "select identification.*,department.d_name from identification,department where identification.bzm=? and identification.d_id=department.d_id ";

问题解决成功。(所属院系名称便为表的链接查询结果)

原文地址:https://www.cnblogs.com/AKsnoopy/p/8883231.html