prob with retrieving data from access

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
bugthefixer
Forum Contributor
Posts: 118
Joined: Mon Mar 22, 2004 2:35 am

prob with retrieving data from access

Post by bugthefixer »

I am trying to retrieve data from access and this is wat i use

Code: Select all

$rs_population = $conn->Execute("SELECT sum(total) as pop FROM tbResponseRA where (((tbResponseRA.Teshil)=$fv)) ");     
     echo $rs_shelter->Fields("shel");
Now the problem is when it couldnt find any data it prints Object id # ..... thats creating trouble for me... is there any way so that i can make it print nothing or 0 rather then Object id #
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

Post by Jean-Yves »

You can use:

Code: Select all

SELECT GREATEST(SUM(total), 0) FROM table WHERE condition
User avatar
Jean-Yves
Forum Contributor
Posts: 148
Joined: Wed Jul 02, 2003 2:13 pm
Location: West Country, UK

Post by Jean-Yves »

Damn, you said Access. Sorry, my code if for MySQL.

(Note to self: learn to READ!)
Post Reply