Adding in code that builds select query.