Answer the question
In order to leave comments, you need to log in
Combine SQL 3 queries into 1 array
Subject, there are 3 requests like this:
$q1=mysql_query("SELECT id,price,group_id,name,description FROM `product` LIMIT 0, 200");
$q2=mysql_query("SELECT id,parent_id,name FROM `product_group` LIMIT 0, 200");
$q3=mysql_query("SELECT file FROM `product_image` ORDER BY `product_image`.`product_id` ASC LIMIT 0, 200");
Answer the question
In order to leave comments, you need to log in
select p.*, p_g.*, p_i.*
from `product` p
left join `product_group` p_g ON p_g.id = p.group_id
left join `product_image` p_i ON p_i.product_id = p.id
ORDER BY p_i.`product_id` ASC
LIMIT 0, 200
Will data from product_group and product_image tables be pulled for products from the first query or not?
If so, then you need to use 2 JOINs here.
@disc
@AMar4enko
Further, based on this data, I'm going to fill xml
$ymlcontent.="<offer id=\"".$row['id']."\" available=\"true\">\n";
$ymlcontent.="<url>http://www.site.ru/product/view/id/".$row['id']."</url>\n";
$ymlcontent.="<price>".$row['price']."</price>\n";
$ymlcontent.="<currencyId>RUR</currencyId>\n";
$ymlcontent.="<categoryId>".$row['group_id']."</categoryId>\n";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question