@RequestMapping(value = "/list")
public String list(Model model, HttpServletRequest request, String flag,
String ghsId, String xsId, String ypId, String yyId)
throws Exception {
String sql = "select a.*,(select name from t_ghs b where a.ghsId=b.id) name ,(select name from t_xs b where a.xsId=b.id) man ,(select name from t_yp b where a.ypId=b.id) hao ,(select name from t_yy b where a.yyId=b.id) ni from t_flow a where 1=1";
if (ghsId != null && !"".equals(ghsId)) {
sql += " and ghsId ="+ghsId;
}
if (xsId != null && !"".equals(xsId)) {
sql += " and xsId ="+xsId;
}
if (ypId != null && !"".equals(ypId)) {
sql += " and ypId ="+ypId;
}
if (yyId != null && !"".equals(yyId)) {
sql += " and yyId ="+yyId;
}
sql += " order by id desc";
List list = db.queryForList(sql);
request.setAttribute("list", list);
return "/admin/flow/list";
}
四联表的级联查询
String sql = "select a.*,(select name from t_ghs b where a.ghsId=b.id) name ,(select name from t_xs b where a.xsId=b.id) man ,(select name from t_yp b where a.ypId=b.id) hao ,(select name from t_yy b where a.yyId=b.id) ni from t_flow a where 1=1";