in reply to checking mysql rows continuously

these are mostly SQL questions, not Perl.

Well ... to get you started with DBI

> then how can i run the query continuously

->fetchrow ° will give you row after row if you don't LIMIT you can run it in a loop

> skip to next row if the previous one status eq to no

I recommend you use DBI#fetchrow_hashref

Fetches the next row of data and returns it as a reference to a hash containing field name and field value pairs. ...

If there are no more rows or if an error occurs, then fetchrow_hashref returns an undef

something like

my $query = $dbh->prepare("SELECT * FROM items ORDER BY created ASC"); + $query->execute(); while ( my $h_fields = $query->fetchrow_hashref() ) { next if $h_fields->{status} eq 'no'; # not needed w +ith WHERE clause ... }

(untested)

Please see SQL tutorials

UPDATE

°) uhm ... DBI has no fetchrow! But ...

$ary_ref = $sth->fetchrow_arrayref; $ary_ref = $sth->fetch; # alias

down-voted for showing wrong code. (Again)

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: checking mysql rows continuously
by bigup401 (Pilgrim) on Dec 08, 2020 at 12:04 UTC

    thanks for your response, am going to try it now