View Single Post
  #1 (permalink)  
Old 06-10-2007, 05:27 PM
biggestperlnerd
Posts: n/a
[SOLVED] MySQL/Perl/Programming quickie?

This is a Perl snippet, so if you know how to do this in Perl, bonus to that. But it's possible there's a MySQL solution for this.

My question is short, how can I update a mysql row ++ (auto-increment a specific field)? It's not the key, either, so I don't think I could add the auto_increment. Correct me if I'm wrong though.

my $data = qq(UPDATE now_time SET time= NOW(), location="$ENV{'H
+TTP_REFERER'}", count=... WHERE ip="$userip");
my $sth = $dbh->prepare($data);
$sth->execute() or die $dbh->errstr;

I'm trying to add +1 to the count field without having to do a separate call to the database just to pull in that value. Is there anyway I can do field_name = field_name +1?

__________________

Digg this Post! Del.Icio.Us this Post! Technorati this Post! Furl this Post! Mister Wong this Post! Newsvine this Post! Spurl this Post! Reddit this Post! Netscape this Post!