SELECT SND.userid, SND.firstname, SND.lastname FROM msg as M JOIN users as SND ON SND.userid = M.msg_from WHERE M.msg_to = ? AND M.received iS NULL IN (SELECT title, age, country FROM MSG) #### SELECT userid, FNAME, LNAME, title, age, country FROM msg as M JOIN users as SND ON SND.userid = M.msg_from WHERE M.msg_to = ? AND M.received iS NULL #### [% FOREACH name IN list %]

userid [% name.userid %]

firstname [% name.FNAME %]

lastname [% name.LNAME %]

title [% name.title %]

age [% name.age %]

country [% name.country %]

[% END %] ##
## #!/usr/bin/perl use strict; use DBI; use Template; my $template = Template->new; my $DBH = get_dbh(); # connect somehow my $janedeo_id = 2; my $sth = $DBH->prepare('SELECT userid, FNAME, LNAME, title, age, country FROM msg as M JOIN users as SND ON SND.userid = M.msg_from WHERE M.msg_to = ? AND M.received iS NULL'); $sth->execute($janedeo_id); my $data = $sth->fetchall_arrayref({}); my $templ =<< "END_HTML";