Gossamer Forum
Quote Reply
DISTINCT in Globals
Hi everybody

here is Marina again

I want to display a list of linkowner an a list of the category

I want to use DISTINCT statement

please help



sub {
my $tags = shift;
my ($cat_id, $cat_name) = each %{$DB->table('Links')->get_categories($tags->{ID})};
my $link_db = $DB->table('Links','CatLinks');
my $sth = $link_db->select({ 'DISTINCT(LinkOwner)' });
my $output = '';
while (my $link = $sth->fetchrow_hashref) {
$output .= qq (<tr><td width="10%" height="25">$link->{'LinkOwner'}</td></tr>);
}
return $output;
}

MarinaSly
Quote Reply
Re: [mkoenig] DISTINCT in Globals In reply to
Hi,

Not yet tested but I think it should be as below

(\"'DISTINCT(LinkOwner)");

Cheers,

Dat

Programming and creating plugins and templates
Blog
Quote Reply
Re: [mkoenig] DISTINCT in Globals In reply to
I think you need to remove the curly brackets

select( 'DISTINCT(LinkOwner)' );

and also change fetchrow_hashref to fetchrow_array

and then $link will contain the value of the Username so you just need

output .= qq ~<tr><td width="10%" height="25">$link</td></tr>~;

Oh and you need a condition statement.

my $cond = GT::SQL::Condition->new( 'isValidated','=','Yes','CategoryID', 'IN', \@$all_ids);
my $sth = $link_db->select( ['DISTINCT(LinkOwner)'],$cond);

I think that's about it.

Last edited by:

afinlr: Jan 18, 2004, 2:34 AM
Quote Reply
Re: [afinlr] DISTINCT in Globals In reply to
it works very good

Thank you afinlrSly

Marina