I have the following code that works pretty smoothly:
sql_cag <- sprintf("SELECT * FROM `CAG_table` WHERE `comp_id` = 1");
df <- dbGetQuery(con, sql_cag)
What I would like to do now, however, is to replace the 1
by a parameter. So like this:
sql_cag <- sprintf("SELECT * FROM `CAG_table` WHERE `comp_id` ='%a'", competitie_id);
df <- dbGetQuery(con, sql_cag)
With a parameter competitie_id
competitie_id <- 1
competitie_id <- as.numeric(competitie_id)
But this returns an empty dataframe. So somehow, something seems to go wrong with the '%a'. Any thoughts where this might go wrong?