hi, probably a silly question i've asked before (I blame the heat for memory loss!), but I've been thinking of ways to streamline my code and DB queries.
some of my code tests for the existence of a record by selecting it, I realise that using a count(1) is much more efficient.
I just wanted confirmation that when using the if statement to check for true, if it is given a number > 1 it is still true.
I.E.
if(cntSQL("Table","WHERE")){do whatever}
or should I explicitly write the condition...
if(cntSQL("Table","WHERE") > 0){do whatever}
my cntSQL routine does the following SQL command...
#Build SQL Statement
my $sel = "SELECT COUNT(1) as COUNT FROM $_[0] WHERE $_[1]";
so the count could be from ZERO to the amount records in table, some checks I do just care a record exists regardless of how many.
thanks 1DMF
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.
some of my code tests for the existence of a record by selecting it, I realise that using a count(1) is much more efficient.
I just wanted confirmation that when using the if statement to check for true, if it is given a number > 1 it is still true.
I.E.
if(cntSQL("Table","WHERE")){do whatever}
or should I explicitly write the condition...
if(cntSQL("Table","WHERE") > 0){do whatever}
my cntSQL routine does the following SQL command...
#Build SQL Statement
my $sel = "SELECT COUNT(1) as COUNT FROM $_[0] WHERE $_[1]";
so the count could be from ZERO to the amount records in table, some checks I do just care a record exists regardless of how many.
thanks 1DMF
"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you.