@org. junit.test
public void TT () {
System.out.println (Ifresultstr ("1,2,3,4,5,6,7,8,9"));
}
public static string Ifresultstr (string id) {
String numo= "0";
if (id!=null&&id!= "") {
String ids[] = Id.split (",");
String resultstr = "";
for (int i = 0; i < ids.length; i++) {
if (Ids[i].equals ("1")) {
ResultStr + = "1,";
} else if (Ids[i].equals ("2")) {
ResultStr + = "2,";
} else if (Ids[i].equals ("3")) {
ResultStr + = "2,";
} else if (Ids[i].equals ("4")) {
ResultStr + = "2,";
} else if (Ids[i].equals ("5")) {
ResultStr + = "2,";
} else if (Ids[i].equals ("6")) {
ResultStr + = "2,";
} else if (Ids[i].equals ("7")) {
ResultStr + = "3,";
} else if (Ids[i].equals ("8")) {
ResultStr + = "3,";
} else if (Ids[i].equals ("9")) {
ResultStr + = "3,";
} else if (Ids[i].equals ("10")) {
ResultStr + = "3,";
} else if (Ids[i].equals ("11")) {
ResultStr + = "4,";
} else if (Ids[i].equals ("12")) {
ResultStr + = "4,";
} else if (Ids[i].equals ("13")) {
ResultStr + = "5,";
} else if (Ids[i].equals ("14")) {
ResultStr + = "5,";
}
}
Remove duplicate numbers such as 1,2,2,2,2,2,3,3,3 removal results = =
string[] Array = Resultstr.split (",");
StringBuilder sb = new StringBuilder ();
for (String Str:array) {
if (Sb.indexof (str)! =-1) {
Continue
}
Sb.append (str). Append (",");
}
String newstr = sb.tostring (). substring (0,sb.length ()-1);
return newstr;
}
return Numo;
}
According to the page of the code corresponding database code for many to one