Selecting columns in a SQL statement

I currently have a Shiny application that extracts data from a Teradata database. The SQL extracts all columns (SELECT *) from the database. My intent is to give the user the option to extract only columns they need.

The server code is currently coded as below:

If (input$views == "DB_TRAN") {
tb = dbGetQuery (conn, Paste0("
select *
from table a
where tran_dt between ' ", input$datarange3[[1]], " '
and ' "input$datarange3[[2]], " '
"))
}

I've updated the UI so it has the columns listed for the user to select. Sample code is below:

UI
CheckboxGroupInput(
"Columns",
"Choose columns to download",
choices = c("column1",
"column2"),
selected = c("column1",
"column2")
)

My question is how do update the Server code so it extracts the columns the user selects?

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.