2013-04-08 64 views
-3

我已經返回正常,但而不是顯示id下面的查詢有沒有去,我可以得到它顯示default_ps_products_manufacturers.nameSQL查詢返回的名字

SELECT `manufacturer_id` 
FROM `default_ps_products` 
INNER JOIN `default_ps_products_manufacturers` ON default_ps_products.manufacturer_id = default_ps_products_manufacturers.id 
+2

是的:只需將所需列添加到SELECT列表中以代替'manufacturer_id' ... – 2013-04-08 19:26:51

回答

2

你嘗試,包括在SELECT該列:

SELECT m.name 
FROM `default_ps_products` p 
INNER JOIN `default_ps_products_manufacturers` m 
    ON p.manufacturer_id = m.id 
2

所以只需添加要選擇像列這

SELECT default_ps_products_manufacturers.name 
FROM default_ps_products 
INNER JOIN default_ps_products_manufacturers 
ON default_ps_products.manufacturer_id = default_ps_products_manufacturers.id