Updated SQL querying to support multiple columns