Monday, 9 September 2013

how to select and set value as 0 even if there is no value or data stored in database

how to select and set value as 0 even if there is no value or data stored
in database

is there any select query that set value as 0 even if it is empty or no
record stored in database? because i am trying to subtract values from 2
different table. but the problem is that i cant subtract the the tables if
one of them is no data stored. here is my code.this code can subtract if
both tables have value. hoping you help. i try posting from different blog
or site but can't get the result.
$result = mysql_query("SELECT (SELECT SUM(s.total)-SUM(r.total)
FROM rsales AS s WHERE r.pcode=s.pcode
) as total,

No comments:

Post a Comment