I was wanting to select certain fields from 3 different tables and link by the id_product? i can't seem to find if a join or union should be used? I have tried the following already but had the error appear
SELECT id_product, price, wholesale_price, id_category_default, id_shop_default, description, description_short, link_rewrite, meta_description, meta_keywords, meta_title, name, id_shop, weight
from ps_product, ps_product_lang, ps_product_attribute_shop
where ps_product.id_product = ps_product_lang.id_product
and ps_product_lang.id_product = ps_product_attribute_shop.id_product
Error Code: 1052. Column 'id_product' in field list is ambiguous 0.00031 sec
The tables and fields that I require are:
ps_product
----------
id_product,
price,
wholesale_price,
id_category_default,
id_shop_default.
ps_product_lang
---------------
id_product,
description,
description_short,
link_rewrite,
meta_description,
meta_keywords,
meta_title,
name.
ps_product_attribute_shop
-------------------------
id_product,
id_shop,
price,
weight.
any help would be greatly appreciated
Thanks for all your help.
I have managed to get what I was looking for using:
Select ps_product.id_product, ps_product.price, ps_product.wholesale_price, ps_product.id_category_default, ps_product.id_shop_default, ps_product_lang.description, ps_product_lang.description_short, ps_product_lang.link_rewrite, ps_product_lang.meta_description, ps_product_lang.meta_keywords, ps_product_lang.meta_title, ps_product_lang.name, ps_product_attribute_shop.id_shop, ps_product_attribute_shop.price, ps_product_attribute_shop.weight
FROM ps_product LEFT JOIN ps_product_lang on ps_product.id_product = ps_product_lang.id_product LEFT JOIN ps_product_attribute_shop ON ps_product.id_product = ps_product_attribute_shop.id_product
Probably a long way around but easier for me to follow