Gossamer Forum
Home : General : Databases and SQL :

SQL Statement for finding words in ALL CAPS?

Quote Reply
SQL Statement for finding words in ALL CAPS?
Hi,

I like to filter my LinksSQL site submissions and a pet hate is words in ALL CAPS. I'm not too good with SQL and wondered if there's an SQL statement I can use to search fields in my Links table for words in ALL CAPS, e.g.;

"Get low price VIAGRA NOW!"
"MUSIC at the best DISCOUNT prices"
etc...

If not, is there a method of selecting ALL CAPS words with a certain character length, say 5 characters or more?

Any help appreciated Smile

All the best
Shaun
Quote Reply
Re: [qango] SQL Statement for finding words in ALL CAPS? In reply to
You could do with with GT::SQL, I personally don't know of a way with SQL but I didn't look too hard Angelic

Code:
my $sth = $DB->table('Links')->select( 'ID', 'Title' );

print $IN->header();
while (my ($id, $title) = $sth->fetchrow) {
if ($title =~ /[A-Z]{5,}/) {
print "The title of record $id has CAPS<br>";
}
}
Quote Reply
Re: [Paul] SQL Statement for finding words in ALL CAPS? In reply to
Paul,

Excellent! I added it to Tools.pm and created an output page and it works like a charm. I've even added a 'delete' button alongside so I can get rid of them in one go Smile

Just one quick question; how would I change the selection so that only those links with "isValidate=No" would appear in the results? (I'd hate to delete active links!)

Many thanks

All the best
Shaun
Quote Reply
Re: [qango] SQL Statement for finding words in ALL CAPS? In reply to
Change:

my $sth = $DB->table('Links')->select( 'ID', 'Title' );

to

my $sth = $DB->table('Links')->select( 'ID', 'Title', { isValidated => 'No' });
Quote Reply
Re: [Paul] SQL Statement for finding words in ALL CAPS? In reply to
Thanks Paul Smile

All the best
Shaun