Passing table name as a variable in Mysql query
15 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello Experts,
I am trying to pass table name as a variable in mysql query, does anybody knows that is it possible or not?
PS:If I writes table name insead of variable, it works fine.
%I want something like this
datasource='mysql database name';
conn=database(datasource,'',''); %establishing connection to database
tablename='current_records'; %name of mysql table
sqlquery = ['SELECT id FROM ''' tablename ''''];
result = select(conn,sqlquery);
%This one works fine
datasource='mysql database name';
conn=database(datasource,'',''); %establishing connection to database
sqlquery = ['SELECT id FROM current_records'];
result = select(conn,sqlquery);
0 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Database Toolbox dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!