2016-02-13 55 views
-3
select sub.sub_product_image_path, sub.sub_product_id 
    from `portal_products(sub category)` sub , 
     `portal_products(main category)`main 
    where sub.product_id=main.product_id ; 

select sub.sub_product_image_path, sub.sub_product_id 
    from `portal_products(sub category)` sub 
    where sub.product_id=35; 
+0

使用聯盟或聯盟所有會工作 – Hytool

+0

要將'portal_products(子類別)'描述爲表名的不好選擇,那麼可以低估 – Strawberry

回答

1

如果我得到你的要求正確

select sub.sub_product_image_path,sub.sub_product_id 
from `portal_products(sub category)` sub 
inner join `portal_products(main category)`main on 
sub.product_id=main.product_id 
where sub.product_id=35; 

OR

select sub.sub_product_image_path, sub.sub_product_id 
from `portal_products(sub category)` sub , 
inner join `portal_products(main category)`main on sub.product_id=main.product_id ; 

union all 

select sub.sub_product_image_path, sub.sub_product_id 
from `portal_products(sub category)` sub 
where sub.product_id=35 
+0

正常工作,非常感謝先生 –