make 2 queries into one?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,
 
Been trying to come up with a way to make the following queries into one
which would speed up the processing I think.
 
Code:
 
 
$mQuery = db_query("SELECT manufacturer FROM kcs_threads GROUP BY
manufacturer ORDER BY manufacturer");
while ($mResult = db_fetch($mQuery)) {
 
                $query = "select t.type, t.newUrlType, g.threadType,
g.groupName, g.groupNameUrl
 FROM kcs_threads t LEFT JOIN kcs_threadgroups g ON t.type =
 g.threadType WHERE t.manufacturer =
".escapeQuote($mResult['manufacturer'])." ORDER BY t.type, g.groupName";
 
                $result = db_query($query);
 
                while($thread = db_fetch($result)) {
 
             }
}
 
 
In the first query I am grabbing the Manufacturer from the threads
table.
 
Then in the second query I am making a LEFT JOIN to match up some stuff
based on the t.manufactuer equalling the manufacturer of the first
query.
 
ANY possibilities here or is this it?
 
Thanks!
 
Aaron

[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux