我在 MYSQL 数据库中有这张表(见附图)
我想检索三个不同公寓的“电缆”列。到目前为止,这就是我的代码中的内容,但它不起作用,知道为什么吗?
try
{
//Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
//Connection connection=DriverManager.getConnection("jdbc:odbc:db1","","");
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection=DriverManager.getConnection("jdbc:mysql://localhost/etoolsco_VecinetSM?user=etoolsco&password=g7Xm2heD41");
Statement statement=connection.createStatement();
String query;
query="SELECT cable FROM flatene2013 WHERE Apto='5C' JOIN SELECT cable FROM flatene2013 WHERE Apto='5Cest1' JOIN SELECT cable FROM flatene2013 WHERE Apto='5Cest2'";
ResultSet resultSet=statement.executeQuery(query);
while(resultSet.next())
{%>
<tr>
<td> </td>
<td align="right"><font size="-1"><%out.println(resultSet.getBigDecimal(1)+"");%></font></td>
<td align="right"><font size="-1"><%out.println(resultSet.getBigDecimal(2)+"");%></font></td>
<td align="right"><font size="-1"><%out.println(resultSet.getBigDecimal(3)+"");%></font></td>
</tr>
<%
}