Copyright: without her consent, and not to reprint the article, if reproduced please note the link address! https://blog.csdn.net/qq_38366657/article/details/89281625
DataTable dataTable; if("".equals(DEPT_ID)){ dataTable=ticket.getDB().getDataTable("select DEPT_ID,NOTICE_ID from ES_NOTICE_TARGET where NOTICE_ID=? ",noticeid); }else{ String strsqlS="select DEPT_ID,NOTICE_ID from ES_NOTICE_TARGET where NOTICE_ID='"+noticeid+"' and DEPT_ID IN ("+DEPT_ID+")"; dataTable=ticket.getDB().getDataTable(strsqlS); } String NOTICEID=""; for (int i=0;i<dataTable.getRow().size();i++){ if(i+1==dataTable.getRow().size()){ NOTICEID +="\'"+dataTable.getRow(i).getStringValue("NOTICE_ID")+dataTable.getRow(i).getStringValue("DEPT_ID")+"\'"; }else{ NOTICEID +="\'"+dataTable.getRow(i).getStringValue("NOTICE_ID")+dataTable.getRow(i).getStringValue("DEPT_ID")+"\',"; } }