MATLAB Answers

Nan Shen

Can we see query fields in Workplace?

Asked by Nan Shen
on 23 Jan 2013

Can we also pull query fields into workplace when we query data? How to do it?


database question

Could you give an example of what you would like to do?

I use query builder to query data from our database. it pops up a variable with data I need. But what I also need are names of those columns (fields in Query Builder). Can we have another varible in workspace showing the field names? thanks!



No products are associated with this question.

1 Answer

Answer by the cyclist
on 25 Jan 2013

There is no way that I know of to return the column names along with the data of those columns. (It would be a bit odd to do so, since the names and data may be of different types.)

You can query the metadata of the database to get column names. For example, in postgresql you can write

SELECT attname , typname FROM pg_attribute , pg_type WHERE   
typrelid=attrelid AND typname = 'table_name' ;

to find the columns for the table named table_name.


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!