sql - MySQL trouble getting value from a third table in query -
i need retrieving value third table
product_attribute | id_product_attribute | id_product | reference | ean13 | product_attribute_combination | id_attribute | id_product_attribute | attribute_lang | id_attribute | name |
i did query below product list, want name
attribute_lang , don't know how.
can me on this?
this have now
select t1.id_product, t1.reference, t2.name, t1.price, if(length(trim(t1.ean13)) = 0, t1.id_product, t1.ean13) ean13 /*prefix*/product_attribute t1 inner join /*prefix*/product_lang t2 on (t1.id_product = t2.id_product , t2.id_lang = /*current_language_id*/) t1.id_product /*products_id_list*/
you need add 2 more joins:
left join /*prefix*/product_attribute_combination t3 on t3.id_product_attribute=t1.id_product_attribute left join /*prefix*/attribute_lang t4 on t4.id_attribute=t3.id_attribute
and add t4.name selected column
the result this:
select t1.id_product, t1.reference, t2.name, t1.price, if(length(trim(t1.ean13)) = 0, t1.id_product, t1.ean13) ean13, t4.name /*prefix*/product_attribute t1 inner join /*prefix*/product_lang t2 on (t1.id_product = t2.id_product , t2.id_lang = /*current_language_id*/) left join /*prefix*/product_attribute_combination t3 on t3.id_product_attribute=t1.id_product_attribute left join /*prefix*/attribute_lang t4 on t4.id_attribute=t3.id_attribute t1.id_product /*products_id_list*/
Comments
Post a Comment