Clear Filters
Clear Filters

Selecting from database using multiple conditions (SQL)

4 views (last 30 days)
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.

Answers (0)

Community Treasure Hunt

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

Start Hunting!