You are here: Combining recordsets « PHP « IT news, forums, messages
Combining recordsets

Posted by Mike Smith on 07/20/05 19:38

I'm wondering if someone has a better solution then I've come up with.
I've got a few reports that pull from various tables. Some times I'm
not able to put all the tables into a single query/view. So I end up
with a master query and 1 (or more) supporting queries. I'm using
MSSQL 2000/IIS/PHP4/ADODB. This may be my own weakness in designing a
query, I'm willing to learn if it is. So I've ended up doing things
like:

function formula($part,$array){
//imagine a formula to calculate weeks in pipe for a part
foreach($array AS $val){
if($val[0]==$part){
$qty = $val[1];
}
}
return $qty;
}


$q1 = "SELECT part, fcast FROM parts";
$rs1 = $conn->Execute($s);
$rs1_arr = $rs1->GetArray();


$q2 = "SELECT part, qty FROM pos";
$rs2 = $conn->Execute($s);
$rs2_arr = $rs2->GetArray();

foreach($rs1_arr AS $data){
echo "Part: ".$data[0];
echo "Forecast: ".$data[1];
echo "POs: ".formula($data[0],$rs2_arr);
}

This is not a wonderful example, because I could LEFT JOIN pos to
parts. But I have more complex queries that have several INNER/LEFT
joins that once I bring in that last table to complete my query it
(the last table) skews my sums. Really I'm just wondering if others
have come across

--
Mike

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация