$query="SELECT Company.CompanyID, Company.Name, Company.Street, Suburb.Name AS s_name, Company.Priority, Company.Telephone, Company.Email, Company.Web, Company.Map, Company.Editorial, Company.BookIt, OrderTable.OrderID FROM Category, Company, CompanyAmenity, SubAmenity, Subcategory, Suburb, Contact, OrderTable WHERE Company.CompanyID = CompanyAmenity.CompanyID AND Company.SuburbID = Suburb.SuburbID AND Suburb.CityID = $cityID AND CompanyAmenity.SubAmenityID = SubAmenity.SubAmenityID AND SubAmenity.SubcategoryID = Subcategory.SubcategoryID AND Subcategory.SubcategoryID = $subID AND Company.ActStatus = 1 and Company.CompanyID = Contact.CompanyID AND Contact.ContactID =OrderTable.ContactID GROUP BY Company.Name ASC ORDER BY Priority, Company.Name limit $set, $limit";
$result = mysql_query ($query,$db_link_id);
$reult_num=mysql_num_rows($result);
if($reult_num !="0"){
while($myrow = mysql_fetch_array($result)){
$company_id=$myrow[CompanyID];
$company = $myrow[Name];
$address = $myrow[Street];
$suburb = $myrow[s_name];
$telephone = $myrow[Telephone];
$email = $myrow[Email];
$web = $myrow[Web];
$map = $myrow[Map];
$editorial=$myrow[Editorial];
$book=$myrow[BookIt];
$order_id=$myrow[OrderID];
This is the code i am currently using. A large multy table query. I really need all of that query in their except the OrderID bit. Is it quicker to get the OrderID via a second seperate query or just leave it in the first multy table join. I have resently struc some major problems with another cross table join that i fixed by adding OrderID into this main query. But this table will soon have 150-180k company records in it and the OrderTable about the same.Is this likely to create a alot slower query. I am really apealing for someone who has alot of DBA experaince or something to help me. I have only been doing this for 6mnth on a small DB and have never encountered these problems. Need some guidence andsuggestions
thanks