select columns from a table by name in matlab

If you want to select specific columns from a table in Matlab, you can use the following syntax:

main.m
conn = database(dbName, userName, password);
sqlquery = 'SELECT column1, column2, column3 FROM tableName';
data = fetch(conn, sqlquery);
137 chars
4 lines

In this example, dbName, userName, and password should be replaced with your actual database name, username, and password. tableName should be replaced with the name of the table you want to query, and column1, column2, and column3 should be replaced with the names of the columns you want to select.

The fetch function will return the requested data in a cell array.

related categories

gistlibby LogSnag