作者:加勒比小洁_149 | 来源:互联网 | 2014-07-09 16:02
Oracle级联查询Java代码Stringsql"selecta.node_name,p.name,p.path_id,a.id,a.alarm_level,a.alarm_status,a.description,a.alarm_startfrompathp"+"leftjoina..
Oracle级联查询
String sql = "select a.node_name,p.name,p.path_id,a.id,a.alarm_level,
a.alarm_status,a.description,
a.alarm_start from path p "
+ "left join alarm a on a.path_id = p.path_id"
+ wheresql;
www.2cto.com
//首先是主表, 表结构
String historysql = " union "
+ "select h"+i+".node_fullname as node_name,p"+i+".name,p"+i+".path_id,h"+i+".id,h"+i+".alarm_level,h"+i+".
alarm_status,h"+i+".description,h"+i+".alarm_start from path p"+i
+ " left join historyalarm_"+i+" h"+i+" on h"+i+".path_id = p"+i+".path_id"
+ " where p"+i+".path_id in ("+ pathArray +")"
;
然后字段一定要对齐了,要有条件查询,必须表明缩写不跟主表一样