38 line SQL query to return tags for photos