preCharge Forums - View Single Post - testing for true greater than 1
View Single Post
Old 07-07-2006   #1 (permalink)
avery
Junior Member
 
Join Date: Jul 2006
Age: 43
Posts: 5
Default testing for true greater than 1

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
Avery
avery is offline   Reply With Quote

 
Bankruptcy | Cash Advance | Loans | Debt Consolidation | Advertising