Passing table name as a variable in Mysql query
조회 수: 15 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Database Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!