2011-06-09 40 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';