Gossamer Forum
Home : Products : Gossamer Links : Development, Plugins and Globals :

Field1 not equal to Field2

Quote Reply
Field1 not equal to Field2
Hi,

I would like to list all links with Field1 not equal to Field2.

This is producing the desired result but how to convert this into a global Wink

SELECT ID, Title
FROM `Links`
WHERE Field1 != Field2


Thanks in advance!
Quote Reply
Re: [Payooo] Field1 not equal to Field2 In reply to
Maybe;

Code:
sub {

my $cond = GT::SQL::Condition->new('Field1','!=','Field2');
my $sth = $DB->table('Links')->select($cond) || return $GT::SQL::error;

while (my $hit = $sth->fetchrow_hashref) {
# do stuff here
}
}

Untested, but it should work Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] Field1 not equal to Field2 In reply to
Thanks Andy! Smile

I ended up using:


sub {
my $output;
my $cond = GT::SQL::Condition->new('Field1','!=','Field2');
my $sth = $DB->table('Links')->select($cond) || return $GT::SQL::error;
my @output;
while (my $hit = $sth->fetchrow_hashref) {
push (@output, $hit);
}
return {
diff_loop => \@output };
}



But, somehow this caches results. Crazy

If I change values to match (Field1 = Field2) this global will still show this ID/link ...

Thanks in advance!
Quote Reply
Re: [Payooo] Field1 not equal to Field2 In reply to
Not certain but I think you probably need a \ before 'Field2' - otherwise it will be looking for the text 'Field2' rather than the field value.
Quote Reply
Re: [afinlr] Field1 not equal to Field2 In reply to
Yes! Smile

Thanks afinlr!