You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
if (cityName != null && !cityName.isEmpty()) {
if (hasCondition) {
sql.append(" AND ");
} else {
sql.append(" WHERE ");
hasCondition = true;
}
sql.append("province_table.city_name = '").append(cityName).append("'");
}