Forums

Combine Multiple SQL Queires in One Form with PHP

mkusens 09 Apr, 2014
I am trying to build a report view from data in a table. The report view has to execute about 8 different SQL queries to tabulate data from the table and then I want to use a PHP script to combine the results of the various queries into a single view. How would I go about this?

To elaborate a bit more, below are two sample SQL queries I have and as you see it sums data in these fields and lines them up in columns. I want to create an html view that shows the columns by writing some PHP:

select ('Kiosk') as Product, total.*, (Development + QA + Install + Support + Documentation + Sales + Management + Admin) as Total from
(select sum(kioskdev) as Development, sum(kioskqa) as QA, sum(kioskinstall) as Install, sum(kiosksupport) as Support, sum(kioskdocumentation) as Documentation, sum(kiosksales) as Sales, sum(kioskmgmt) as Management, sum(kioskadmin) as Admin
from zpebk_timeinputlog
where daterange = '04_1_14') as total

select ('Pcs') as Product,total.*, (Development + QA + Install + Support + Documentation + Sales + Management + Admin) as Total from
(select sum(pcsdev) as Development, sum(pcsqa) as QA, sum(pcsinstall) as Install, sum(pcssupport) as Support, sum(pcsdocumentation) as Documentation, sum(pcssales) as Sales, sum(pcsmgmt) as Management, sum(pcsadmin) as Admin
from zpebk_timeinputlog
where daterange = '04_1_14') as total
GreyHead 09 Apr, 2014
Hi mkusens,

The simplest way to build complex queries in CCv4 is to use a MySQL View in the database. If I remember correctly you need to make a small hack in the CC code to get this to work but then it's fine.

Bob

Bob
This topic is locked and no more replies can be posted.