Monday, 2 September 2013

Use the result from a query table into another query

Use the result from a query table into another query

There are 3 different tables and from first table i get the "contact_id"
and based on this i would like to do the SUM into the next 2 tables and
then MINUS the tables as in the code bellow.
I am trying to use the result "contact_id" from the first query into the
following queries
SELECT (
SELECT id FROM civicrm_contact WHERE first_name LIKE 'test2' ) AS contact_id
================================================================================
SELECT (
SELECT SUM(total_amount) FROM civicrm_contributionWHERE contact_id=
)
(
SELECT SUM(fee_amount) FROM civicrm_participantWHERE contact_id=
) As RemainingPoints

No comments:

Post a Comment