MySQL Forums
Forum List  »  Perl

Not Exists-module
Posted by: Jelmer
Date: January 25, 2007 11:17AM

Hi guys,

I've got a little experience with the combination of perl and mysql, but not much further than the basics. Now I'm tryin to write something with the 'not exists' or the 'not in'-module. But it just isn't working, so I must have done something wrong.

This is the part of the perl-script:


foreach $value (values %search_terms_hash) {
push (@searchterms, $value);
}

foreach $term (@searchterms) {
my $sth = $dbh->prepare("SELECT * FROM categories WHERE (`title` LIKE '$term' OR `description` LIKE '$term' OR `keywords` LIKE '$term' OR `filename` LIKE '$term') ORDER BY title") || print "could not access database";
$sth->execute();
while (my $results = $sth->fetchrow_hashref) {
my $catid = $results->{id};
my $cattitle = $results->{title};
my $catfilename = $results->{filename};
my $cattotaal = $results->{totaal};
$excatmatchresults{$catid} = "$catid|$cattitle|$catfilename|$cattotaal";
} $sth->finish;

my $sth = $dbh->prepare("SELECT * FROM categories WHERE id NOT EXISTS (SELECT id FROM categories WHERE title = 'Ajax')") || print "could not access database";
$sth->execute();
while (my $results = $sth->fetchrow_hashref) {
my $catid = $results->{id};
my $cattitle = $results->{title};
my $catfilename = $results->{filename};
my $cattotaal = $results->{totaal};
$catmatchresults{$catid} = "$catid|$cattitle|$catfilename|$cattotaal";
} $sth->finish;

And I'm talking about this part:

WHERE id NOT EXISTS (SELECT id FROM categories WHERE title = 'Ajax')")


The part behind id NOT EXISTS is just a test-query, because then I can see if it's already working. I'm having a feeling that it's just missing a bracket or a ; or something. Thank you for your help!

Options: ReplyQuote


Subject
Written By
Posted
Not Exists-module
January 25, 2007 11:17AM
January 25, 2007 11:47AM
January 26, 2007 04:38AM
January 26, 2007 04:47AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.