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
24
25
26
27
28
29
30
31
32
33
private static String makeSQL(java.sql.Date start, java.sql.Date end, String performers) {
String sql = "";
if (start == null && end == null && performers.equals("all")) {
System.out.println("1");
sql = "SELECT * FROM reports";
} else if (start == null && end == null) {
System.out.println("2");
System.out.println("Performer : " + performers);
sql = "SELECT * FROM reports WHERE \"performer\"=\'" + performers + "\'";
} else if (start != null && end == null && performers.equals("all")) {
System.out.println("3");
sql = "SELECT * FROM reports WHERE \"startdate\">=\'" + start + "\'";
} else if (start == null && end != null && performers.equals("all")) {
System.out.println("4");
sql = "SELECT * FROM reports WHERE \"finishdate\"<=\'" + end + "\'";
} else if (start != null && end != null && performers.equals("all")) {
System.out.println("5");
sql = "SELECT * FROM reports WHERE \"finishdate\"<=\'" + end + "\' AND \"startdate\">=\'" + start + "\'";
} else if (start != null && end == null) {
System.out.println("6");
sql = "SELECT * FROM reports WHERE \"startdate\">=\'" + start + "\' AND \"performer\"=\'" + performers + "\'";
} else if (start == null && end != null) {
System.out.println("7");
sql = "SELECT * FROM reports WHERE \"finishdate\"<=\'" + end + "\' AND \"performer\"=\'" + performers + "\'";
} else if (start != null && end != null) {
System.out.println("8");
sql = "SELECT * FROM reports WHERE \"startdate\" >=\'" + start + "\' AND \"performer\"=\'" + performers + "\'" +
" AND \"finishdate\"<=\'" + end + "\'";
}
return sql;
}