sql拼接函数:
1 public static String Instructor_sql_whole_study(String[] val_ids,String[] val_values) 2 { 3 String sql="SELECT * from student_1_score where"; 4 for(int i=0;i<val_ids.length;i++) 5 { 6 sql+=Instructor_sql_study(sql,val_ids[i])+" like ‘%"+val_values[i]+"%‘"; 7 } 8 return sql; 9 } 10 public static String Instructor_sql_study(String sql,String id) 11 { 12 String str=""; 13 String and_str=" and "; 14 if(sh.getExpString("where$",sql).size()>0) 15 { 16 and_str=" "; 17 } 18 switch (id) 19 { 20 case "1": 21 str=and_str+"name_student";break; 22 case "2": 23 str=and_str+"name_course";break; 24 case "3": 25 str=and_str+"credit";break; 26 case "4": 27 str=and_str+"term";break; 28 case "5": 29 str=and_str+"class";break; 30 } 31 return str; 32 }