Home > other >  How to choose column in sql select using variable in Qt
How to choose column in sql select using variable in Qt

Time:11-22

I am writing a function that will take a string variable and work with a column with the name of this variable, but i can't figure out how to write variable in select

I tried this where test is QString variable with value company, but it didnt work like if there was company without variable

QString test = "company";
QSqlQuery password = db->exec("SELECT password FROM '" test "'");

CodePudding user response:

Worked with deleted '' of the variable.

QSqlQuery password = db->exec("SELECT password FROM " test "");
  • Related