String sql="SELECT a.ID,a.VISITOR_TEXT,a.COMPANY_TEXT,a.CONTACT,a.PERSON_TO_MEET,a.DEPARTMENT_TEXT,a.FLOOR,b.BELONGING_TYPE,b.BELONGING_TEXT ,a.INTIME, c.EXIT_TIME FROM tm_visitor a LEFT JOIN tm_belonging b ON b.BID=a.ID LEFT JOIN tm_exit c ON c.ID=a.ID limit "+i+",10";
System.out.println(sql);
ResultSet rs=st.executeQuery(sql);
while(rs.next())
{
ar.add(rs.getInt("ID"));
ar.add(rs.getObject("VISITOR_TEXT"));
ar.add(rs.getObject("COMPANY_TEXT"));
ar.add(rs.getObject("CONTACT"));
ar.add(rs.getObject("PERSON_TO_MEET"));
ar.add(rs.getObject("DEPARTMENT_TEXT"));
ar.add(rs.getObject("FLOOR"));
ar.add(rs.getObject("BELONGING_TYPE"));
ar.add(rs.getObject("BELONGING_TEXT"));
ar.add(rs.getObject("INTIME"));
ar.add(rs.getObject("EXIT_TIME"));
}
<tr>
<td align="center"><input type="text" name="id" value="<%=itr.next()%>" readonly size="15"></td>
<td align="center"><input type="text" name="visitorname" value="<%=itr.next()%>" readonly size="20"></td>
<td align="center"><input type="text" name="company" value="<%=itr.next()%>" readonly size="20"></td>
<td align="center"><input type="text" name="contact" value="<%=itr.next()%>" readonly size="10"></td>
<td align="center"><input type="text" name="whometomeet" value="<%=itr.next()%>" readonly size="20"></td>
<td align="center"><input type="text" name="department" value="<%=itr.next()%>" readonly size="20"></td>
<td align="center"><input type="text" name="floor" value="<%=itr.next()%>" readonly size="7"></td>
<td align="center"><input type="text" name="btype" value="<%=itr.next()%>" readonly size="15"></td>
<td align="center"><input type="text" name="bel" value="<%=itr.next()%>" readonly size="15"></td>
<td align="center"><input type="text" name="intime" value="<%=itr.next()%>" readonly size="20"></td>
<td align="center"><input type="text" name="exittime" value="<%=itr.next()%>" readonly size="20"></td>
</tr>
执行上述查询后,如果 tm_exit.EXIT_TIME 中的值不存在,则在 JSP 表文本框中显示 NULL 我该如何避免这种情况
我试过了:
<%!
String blanknull(String s) {
return (s == null) ? "" : s;
}
%>
但没有用,请帮忙?
这是我用来获取数据的查询
SELECT a.ID,a.VISITOR_TEXT,a.COMPANY_TEXT,a.CONTACT,a.PERSON_TO_MEET,a.DEPARTMENT_TEXT,a.FLOOR,b.BELONG ING_TYPE,b.BELONGING_TEXT ,a.INTIME, c.(ifnull(EXIT_TIME,'NA')) as EXIT_TIME FROM tm_visitor a LEFT JOIN tm_b elonging b ON b.BID=a.ID LEFT JOIN tm_exit c ON c.ID=a.ID;
但给出以下错误
ERROR 1064 (42000):您的 SQL 语法有错误;检查与您的 MySQL 服务器版本相对应的手册,以了解在 '(ifnull(EXIT_TIME,'NA')) 作为 EXIT_TIME FROM tm_visitor a LEFT JOI N tm_belonging 附近使用的正确语法