我有 6 个表 1. Products p 2. Attributes a 3. Product and Attribute pa (ID, pID, aID) 4. Company c 5. USer u 6. Company and User cu (ID, cID, uID)
现在在管理员中,我想查看公司产品及其属性。
SELECT p.ID, p.name
from products p
LEFT JOIN Product and Attribute pa ON pa.pID = p.ID
LEFT JOIN Attributes a ON a.pID = pa.aID
LEFT JOIN Company and User cu ON cu.UiD = p.uID AND cu.cID = 121 (spcific company id)
WHERE 1
GROUP BY p.ID