I have the following code in my C++ program:
query_state = mysql_query(connection, "select * from cplpl");
if I want to replace the table name,cplpl, by a variable in my C++ program, how do I do it?
basically, I've created
string tblnm="cplpl";
but then if I run
query_state = mysql_query(connection, "select * from tblnm");
it looks for the table tblnm. I tried $tblnm also like you can do in Perl, but that doesn't work either
Is there a way I can fix this? thx!
EDIT: If I rewrite this as follows:
string tblnm="test";
string qrycd="select * from " +tblnm;
query_state = mysql_query(connection, qrycd.c_str());
it works, however, if I want to add a where clause
string qrycd1="where fname like '%Bob%';";
and rewrite the code as
string qrycd="select * from " +tblnm +qrycd1;
query_state = mysql_query(connection, qrycd.c_str());
I get an error..