Hi.
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?