Home >Database >Mysql Tutorial >导出结果跟查询结果不一致_MySQL
1、错误原因
2、错误原因
上面左侧图是SQL语句查询出来的结果,右侧是导出Excel展示的数据,结果发现两者竟然不一致
3、解决办法
拼接的SQL:
sql.append("SELECT CONCAT((@rowNum := @rowNum + 1),'') AS rownum,t.* FROM(");
Map<string,object> map=(Map<string, object="">) data.get(i); HSSFRow datarow = sheet.createRow(i+1); HSSFCell cell0 = datarow.createCell(0); HSSFRichTextString t0 = new HSSFRichTextString((String)map.get("rownum")+""); cell0.setCellValue(t0);</string,></string,object>rownum是数值型的,在循环中取值时,rownum变为null
Map<string,object> map=(Map<string, object="">) data.get(i); HSSFRow datarow = sheet.createRow(i+1); HSSFCell cell0 = datarow.createCell(0); HSSFRichTextString t0 = new HSSFRichTextString(map.get("rownum")+""); cell0.setCellValue(t0); </string,></string,object>去掉map前的(String),并清除一下缓存