public String joinQuery(String name, String phone, String pid) {
		String query = "SELECT * FROM Visitor_visits v, Prisoner p WHERE ";
		if (notNorE(name) && notNorE(phone) && notNorE(pid)) {
			query += "vname LIKE '%" + name + "%' AND phone = " + phone
					+ " AND p.pid = " + pid + " AND p.pid = v.pid";
		} else if (notNorE(name) && notNorE(phone)) {
			query += "vname LIKE '%" + name + "%' AND phone = " + phone
					+ " AND p.pid = v.pid";
		} else if (notNorE(name) && notNorE(pid)) {
			query += "vname LIKE '%" + name + "%' AND p.pid = " + pid
					+ " AND p.pid = v.pid";
		} else if (notNorE(phone) && notNorE(pid)) {
			query += "phone = " + phone + " AND p.pid = " + pid
					+ " AND p.pid = v.pid";
		} else if (notNorE(name)) {
			query += "vname LIKE '%" + name + "%'" + " AND p.pid = v.pid";
		} else if (notNorE(phone)) {
			query += "phone = " + phone + " AND p.pid = v.pid";
		} else if (notNorE(pid)) {
			query += "p.pid = " + pid + " AND p.pid = v.pid";
		} else {
			return error;
		}
		return sendQuery(query);
	}