Preparing select query with variable column list