private String constructTagAttributesQuery(String regExp,
			String qualification, String[][] values) {
		String selectqry = "";
		String columnName = "";
		if (qualification.equalsIgnoreCase("Tags")) {
			selectqry = " SELECT TAG_ENTITY_UUID FROM TAGS"
					+ " WHERE UPPER(TAG_NAME)";
			columnName = "UPPER(TAG_NAME)";
		} else {
			selectqry = " SELECT ATTRIBUTE_ORGANIZATIONAL_UUID"
					+ " FROM attributes WHERE UPPER(ATTRIBUTE_VALUE)";
			columnName = "UPPER(ATTRIBUTE_VALUE)";
		}
		String qry = selectqry;
		int groups = values.length;
		for (int i = 0; i < groups; i++) {
			int numValues = values[i].length;
			if (regExp.equalsIgnoreCase("on")) {
				qry += " ~* ?";
				for (int j = 1; j < numValues; j++)
					qry += " OR " + columnName + " ~* ?";
			} else {
				qry += " IN (?";
				for (int j = 1; j < numValues; j++)
					qry += ",?";
				qry += ")";
			}
			if (i != groups - 1)
				qry += " INTERSECT " + selectqry;
		}
		return qry;
	}