Selecting from database using multiple conditions (SQL)

1 次查看(过去 30 天)
Hi everyone,
How can I fetch data from the database with multiple conditions that tend to change in my loop.
For example, for one this is what i do
ProjectName = XXX;
a = strcat('''', ProjectName, '''');
curs = ['SELECT ID from Table1 WHERE ProjectName =',a]; cursVessel = fetch(conn,curs);
Now if I want the ID numbers where my ProjectName = XXX, and Country = YYY; How can I do that?. My project name and country would change within a loop that's why I can't say
curs = ['SELECT ID from Table1 WHERE ProjectName =''XXX'' and Country = ''YYY''']; cursVessel = fetch(conn,curs);
Thank you in advance,
If any clarifications is needed, please let me know.

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Database Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by