2011-06-09 59 views
1

我有这两个查询组合两个查询和添加返回到阵列

第一是

select image from product where product_id = '82'; 

返回

data/1B.png 

第二是这

select image from product_image where product_id = '82'; 

返回

data/computer_system.png 
data/post-image.png 
data/13D.png 

所以我试图把它们结合在一起,我在此查询

select p.image, pi.image as additional_images from product as p join product_image as pi on pi.product_id=p.product_id where p.product_id = '82' 

返回此

data/1B.png data/computer_system.png 
data/1B.png data/post-image.png 
data/1B.png data/13D.png 

我需要使用一个查询将返回4点的位置,然后设置得他们到一个PHP阵列$图像

任何想法....我知道我可以做单独的查询,因为我有上面但我会做一个ñarray_merge ....但有没有更好的办法

回答

3
select image from product where product_id = '82' 
union 
select image from product_image where product_id = '82';