Пожалуйста, помогите мне получить данные из разных таблиц в одну таблицу путем поиска значения (Обновлено) из двух таблиц и отображения на странице JSP
Пожалуйста, исправьте меня в инструкции String Query!
Добавление дополнительной информации: мое имя таблицы1 является testraildumptable My table2 name is timesheet
<tr>
<th style="width: 30$">ID</th>
<th style="width: 30$">Created By</th>
<th style="width: 30$">Estimate time</th>
<th style="width: 30$">Timesheet time</th>
<th style="width: 30%">Updated By</th>
</tr>
<%
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/testraildump","roo t","root");
String Query="SELECT id, createdby, estimatetime, executionhours, updatedby from testraildumptable inner join timesheet on testraildumptable.updatedby = timesheet.updatedby where updatedby='"+request.getParameter("search")+"'";
Statement stm=conn.createStatement();
ResultSet rs=stm.executeQuery(Query);
while(rs.next())
{
%>
<tr>
<td><%=rs.getString("id")%></td>
<td><%=rs.getString("createdby")%></td>
<td><%=rs.getString("estimatetime")%></td>
<td><%=rs.getString("executionhours")%></td>
<td><%=rs.getString("updatedby")%></td>
</tr>
<%
}
}
Добавление дополнительной информации: мое имя таблицы1 является testraildumptable My table2 name is timesheet
Для вашей ошибки в консоли: "Обновление столбца" в списке полей неоднозначно "
Так как таблица testraildumptable
и timesheet
имеют свойство столбца с именем updatedby
, поэтому, если запрос, то не знаю, какой из них выбрать.
Вы можете обновить запрос sql, как показано ниже:
String Query="SELECT t1.id, t1.createdby, t1.estimatetime, t1.executionhours, t1.updatedby from testraildumptable t1 inner join timesheet t2 on t1.updatedby = t2.updatedby where t1.updatedby='"+request.getParameter("search")+"'";
width: 30$
? Вы имеете в видуwidth: 30%
верно?