updated psql querying syntax