Prestashop中的Inner Join查询

I would like to join two tables and display the data from the other table in prestashop backoffice.

catalog > products

I'm a newbie, I want to ask how to insert or to code this on prestashop.

I have 2 tables:

  • parts: is not from presta its a custom table from other website.

parts
----------------------------
InvPartNo | InvPartDesc
#123      | testprod

ps_products
----------------------------
Id | InvPartNo
1  | #123 

I want to make it I want the InvPartDesc to be added in the description of the product list in Admin (BO) | Catalog > Products.

----------------------------
result
----------------------------
Id | InvPartNo | InvPartDesc
1  | #123      | testprod

Something like this should work

SELECT 
    ps_products.Id, ps_products.InvPartNo, parts.InvPartDesc, 
FROM ps_products
LEFT JOIN parts ON parts.InvPartNo=ps_products.InvPartNo
GROUP BY ps_products.Id

Your query would be:

$query = Db::getInstance()->executeS(
            'SELECT p.Id, p.InvPartNo, pa.InvPartDesc, 
            FROM '._DB_PREFIX_.'products p 
            INNER JOIN parts pa ON (pa.InvPartNo=p.InvPartNo)'
         );