I have a query which returns two rows of data as count. I want to find sum of the column values. My sql:
(SELECT count(memberid) count FROM `friendRequest`, Member where status = 2 and memberid = sender and receiver = 19) UNION (SELECT count(memberid) count FROM `friendRequest`, Member where status = 2 and memberid = receiver and sender = 19)
I have tried using Select Sum(my above query)
but I am getting error. I just need some of above values.
Advertisement
Answer
Can grab both result sets in a single query:
SELECT count(memberid) count FROM `friendRequest`, Member WHERE status = 2 AND ( (memberid = sender AND receiver = 19) OR (memderid = receiver AND sender = 19) )