我有 5 个表,每个表中的架构是(com_no,uid,date)。我想访问所有表并获取相同 uid 的 com_no。我在 JDBC 中将此查询编写为
String s1= (String)session.getAttribute("uid");
rs1=stat.executeQuery("select distinct com_no from hostel,sports where uid='"+s1+"'");
while(rs1.next()) {
out.println(rs1.getString("com_no"));
}
但是 servlet 例外是:
The specified field 'com_no' could refer to more than one table listed in the FROM clause of your SQL statement.
任何人都可以帮助我改进这个查询或给我一些其他的方法来做到这一点。任何帮助将不胜感激。