in reply to Re: Help with MySQL SELECT into multidimensional array
in thread Help with MySQL SELECT into multidimensional array
It might be possible, and I did start down that road, but the query got pretty scary. I think I'm more comfortable with multiple queries, but maybe I'm wrong. Here are all the queries, the first generates the client list, the rest populate the integer fields:
SELECT c2.id, c2.name as 'client' FROM client c2 WHERE level = 50 and status = 1; SELECT c2.id, c2.name as 'client', count(*) as 'ext' FROM client c1, client c2 WHERE c1.level=100 AND c1.status=1 AND ext.type = "phone" AND c1.parent_client_id = c2.id GROUP BY c1.parent_client_id ORDER BY c2.name; SELECT c2,id, c2.name as 'client', count(*) as 'vm' FROM extension ext, client c1, client c2, extension_prefs exp WHERE ext.client_id = c1.id AND c1.level=100 AND exp.param="voicemail" AND exp.value=1 AND c1.parent_client_id = c2.id AND exp.extension_id = ext.id GROUP BY c2.name; SELECT c2.id, c2.name as 'client', count(*) as 'ivr' FROM extension ext, client c1, client c2 WHERE ext.client_id = c1.id AND ext.type = 'ivr' AND c1.status = 1 AND c1.parent_client_id = c2.id GROUP BY c2.name; SELECT c2.id, c2.name as 'client', count(*) as 'queues' FROM extension ext, client c1, client c2 WHERE ext.client_id = c1.id AND ext.type = 'queue' AND c1.status = 1 AND c1.parent_client_id = c2.id GROUP BY c2.name; SELECT c2.id, c2.name as 'client', sum(if(value<11,1,0)) AS "conf10" FROM extension ext, client c1, client c2, extension_prefs exp WHERE ext.client_id = c1.id AND exp.param="conf_size" AND ext.type="conference" AND c1.parent_client_id = c2.id AND exp.extension_id = ext.id GROUP BY c2.name; SELECT c2.id, c2.name as 'client', sum(if(value<20 AND value>10,1,0)) AS "conf20" FROM extension ext, client c1, client c2, extension_prefs exp WHERE ext.client_id = c1.id AND exp.param="conf_size" AND ext.type="conference" AND c1.parent_client_id = c2.id AND exp.extension_id = ext.id GROUP BY c2.name; SELECT c2.id, c2.name as 'client', sum(if(value>20,1,0)) AS "conf30" FROM extension ext, client c1, client c2, extension_prefs exp WHERE ext.client_id = c1.id AND exp.param="conf_size" AND ext.type="conference" AND c1.parent_client_id = c2.id AND exp.extension_id = ext.id GROUP BY c2.name;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Help with MySQL SELECT into multidimensional array
by runrig (Abbot) on Dec 02, 2011 at 19:09 UTC | |
by btongeorge (Initiate) on Dec 02, 2011 at 21:44 UTC | |
by runrig (Abbot) on Dec 02, 2011 at 23:04 UTC | |
by Marshall (Canon) on Dec 02, 2011 at 23:55 UTC | |
by btongeorge (Initiate) on Dec 05, 2011 at 18:09 UTC | |
by Marshall (Canon) on Dec 06, 2011 at 10:50 UTC |