if (!"".equals(docIdOfAttachmentList) && docIdOfAttachmentList != null) { string IsextFileNull = "select isextfile from docimagefile where docid = ? "; for (int i = 0; i < docIdOfAttachmentList.size(); i++) { String tmptsql = "SELECT MAX(imagefileid) AS imagefileid FROM docimagefile WHERE docid=? AND (isextfile IS NULL OR isextfile='')GROUP BY id ORDER BY imagefileid DESC"; rs.executeQuery(tmptsql, docIdOfAttachmentList.get(i)); while (rs.next()) { imagegileIdOfAttachmentList.add(rs.getString("imagefileid")); } } } 需要添加判断 如果查出来的sql 中 isextfile 等于1 则 获取 docimagefile 表下 docfiletype=12得所有值 应该怎么写
时间: 2024-01-13 21:02:32 浏览: 67
java 中String.equals和==的比较
5星 · 资源好评率100%
你可以在循环中加入一个判断语句,判断查询出来的 isextfile 是否等于1,如果等于1,则执行获取 docimagefile 表下 docfiletype=12 的所有值的操作。具体代码如下:
```
if (!"".equals(docIdOfAttachmentList) && docIdOfAttachmentList != null) {
string IsextFileNull = "select isextfile from docimagefile where docid = ? ";
for (int i = 0; i < docIdOfAttachmentList.size(); i++) {
String tmptsql = "SELECT MAX(imagefileid) AS imagefileid, isextfile FROM docimagefile WHERE docid=? AND (isextfile IS NULL OR isextfile='') GROUP BY id ORDER BY imagefileid DESC";
rs.executeQuery(tmptsql, docIdOfAttachmentList.get(i));
while (rs.next()) {
String isExtFile = rs.getString("isextfile");
if ("1".equals(isExtFile)) {
String tmpsql = "SELECT * FROM docimagefile WHERE docid=? AND docfiletype=12";
rs.executeQuery(tmpsql, docIdOfAttachmentList.get(i));
while (rs.next()) {
// 获取 docimagefile 表下 docfiletype=12 的所有值
}
} else {
String imagegileId = rs.getString("imagefileid");
imagegileIdOfAttachmentList.add(imagegileId);
}
}
}
}
```
阅读全文