private static String makeSQL java sql Date start java sql Date end St

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
private static String makeSQL(java.sql.Date start, java.sql.Date end, String performers) {
String sql = "";
if (start == null && end == null && performers == "all") {
sql = "SELECT * FROM reports";
} else if (start == null && end == null) {
sql = "SELECT * FROM reports WHERE \"perfofrmer\"=" + performers;
} else if (start != null && end == null && performers == "all") {
sql = "SELECT * FROM reports WHERE \"startdate\">=" + start;
} else if (start == null && end != null && performers == "all") {
sql = "SELECT * FROM reports WHERE \"finishdate\"<=" + end;
} else if (start != null && end != null && performers == "all") {
sql = "SELECT * FROM reports WHERE \"finishdate\"<=" + end + "AND \"startdate\">=" + start;
} else if (start != null && end == null) {
sql = "SELECT * FROM reports WHERE \"startdate\">=" + start + "AND \"performer\"=" + performers;
} else if (start == null && end != null) {
sql = "SELECT * FROM reports WHERE \"finishhdate\"<=" + end + "AND \"performer\"=" + performers;
} else if (start != null && end != null) {
sql = "SELECT * FROM reports WHERE \"startdate\" >=" + start + "AND \"performer\"=" + performers +
" AND \"finishdate\"<=" + end;
}
return sql;
}