
% Open connection.
% This assumes the database is stored locally and listens to the default
% port, and there exists a user 'root' with no password
mysql('open','localhost','root','');

% Choose database
mysql('use survey');

% Logic goes here...

% For example,

% This will print the number of times (over all comparisons) that each
% operator was selected, ordered by this number in descending order
mysql(['SELECT name as operator, count '...
       'FROM operators o, '...
       '(SELECT opid, count(*) as count '...
       'FROM comparisons c, results r '...
       'WHERE c.did = r.did AND c.selected = r.id '...
       'GROUP BY opid '...
       'ORDER BY count DESC) t '...
       'WHERE o.id = t.opid']);

% And you can store results in vectors:
% This will return all the comparisons data for the first expierment (out
% of the 70 experiments we designed)
[did,res1,res2,selected]=mysql(['SELECT did,res1,res2,selected '...
       'FROM comparisons c, sessions s '...
       'WHERE c.sid = s.id AND s.expid=1']);


% close connection 
mysql('close');
