Gossamer Forum
Home : General : Databases and SQL :

Re: [sooke] Update records in a table based on a function

Quote Reply
Re: [sooke] Update records in a table based on a function In reply to
Try the following:
Code:
my $cat = $DB->table('Categories');
my $sth = $cat->select;

while (my $category = $sth->fetchrow_hashref) {
my $hc = ($cat->count( { FatherID => $category->{ID} } )) ? 'Yes' : 'No';
$cat->update( { haschildren => $hc }, { ID => $category->{ID} } );
}

Ivan
-----
Iyengar Yoga Resources / GT Plugins
Subject Author Views Date
Thread Update records in a table based on a function Ian 15039 May 15, 2002, 10:46 PM
Thread Re: [sooke] Update records in a table based on a function
yogi 14942 May 16, 2002, 12:27 AM
Post Re: [yogi] Update records in a table based on a function
Paul 14717 May 16, 2002, 12:52 AM
Post Re: [yogi] Update records in a table based on a function
Ian 14763 May 16, 2002, 8:30 AM
Post Re: [yogi] Update records in a table based on a function
Ian 14747 May 16, 2002, 9:05 AM
Thread Re: [yogi] Update records in a table based on a function
Ian 14784 May 16, 2002, 10:22 AM
Thread Re: [sooke] Update records in a table based on a function
Paul 14805 May 16, 2002, 10:45 AM
Post Re: [Paul] Update records in a table based on a function
Ian 14747 May 16, 2002, 10:56 AM
Thread Re: [yogi] Update records in a table based on a function
Ian 14788 May 19, 2002, 4:37 PM
Thread Re: [sooke] Update records in a table based on a function
yogi 14758 May 20, 2002, 6:05 AM
Thread Re: [yogi] Update records in a table based on a function
Ian 14761 May 20, 2002, 8:33 AM
Thread Re: [sooke] Update records in a table based on a function
webmaster33 14785 May 20, 2002, 9:44 AM
Post Re: [webmaster33] Update records in a table based on a function
Ian 14643 May 20, 2002, 9:48 AM
Post Re: [sooke] Update records in a table based on a function
webmaster33 14686 May 20, 2002, 6:18 AM