Retrieve all data from columns apart from id when using MySQL
Show older comments
Hello, I'm new to Matlab and Mysql and need a little help. I have a database which is storing the results of an analysis which repeated 150 times, thus one dataset has 150 results for the specifity etc.
I have managaged to automate it so the data goes into the columns i need, the problem i have is extracting it so it can be displayed in a GUI to later then be graphed.
I was using this to take data out of my database:
smp = exec(conn, 'select sample from smp_table') smp = fetch(smp); get(smp, 'Data')
I know i can switch te "sample" to a "*" to get everything from the table, which is what i want, but I DON't want the primary key and cannot seem to execute this.
This is the code i am using to access all the data i want via command line (terminal) for mysql:
SET @sql = CONCAT("SELECT ", (SELECT REPLACE(GROUP_CONCAT(COLUMN_NAME), 'idTestTbl,', '') FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'TestTbl' AND TABLE_SCHEMA = 'MatSch_2'), ' FROM TestTbl');
prepare stmt1 from @sql;
execute stmt1;
Now i have tried something like this in Matlab, but cannot get it to work:
sql = 'SET @sql = CONCAT("SELECT ", (SELECT REPLACE(GROUP_CONCAT(COLUMN_NAME), "idTestTbl,", '') FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = "TestTbl" AND TABLE_SCHEMA = "MatSch_2"), "FROM TestTbl"); prepare stml from @sql'
smp = exec(conn, sql) smp = fetch(smp); get(smp, 'Data')
Can anyone point me in the right direction? Ultimatly i just want to extract all the contents of my table excluding the primary key column...would like a small script for this as i have 150 columns
Thank you in advance
P.S on Matlab 7.6.0 R2008A
Accepted Answer
More Answers (0)
Categories
Find more on Database Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!