Pass variables to a char?

I'm trying to work with MySQL connector and NTPClient.

I want to pass some variables to my query char.

My current char looks like this:

char selectQuery[] = "SELECT * FROM vocals WHERE date = 10-05-2020";

But I want to be able to define the query, but able to pass some variables into that.
I've searched on the internet and found that I can use sprintf. So it looks like this now:

char selectData[] = "SELECT * FROM %s WHERE date = '%s'";
char selectQuery[50];

currentDate = "10-05-2020";
selectTable = "vocals";

sprintf(selectQuery, selectData, selectTable, currentDate);

Is there a better way to do this? Because I get can't pass on a string into the query line.

How can I do this in a better way?

Your syntax is a bit wrong. Make sure that SelectQuery is big enough to hold everything you want to place in there.

void setup() {
  char SelectQuery[50] = " ";
  char selectTable[] = "vocals"; 
  char currentDate[] = "10-05-2020";
  char selectData[] = "Select * FROM %s WHERE date = %s";
  sprintf(SelectQuery, selectData, selectTable, currentDate);

void loop() {}

I strongly recommend to use snprintf(), which won't write outside of the character array you define for output.

I've lost plenty of time tracking down weird problems due to my own failure to do so.