首页 > 解决方案 > 如何正确使用JOIN

问题描述

标签: sql

解决方案


Your query basically looks right. However, if you want all rows in the first table, then use a LEFT JOIN:

SELECT pe.sku AS SKU, ev.value AS Description
FROM Product_Entity pe LEFT JOIN
     Entity_Varchar ev
     ON ev.entity_id = pe.entity_id AND
        ev.attribute_id = '73';

Rows that don't match will have NULL for the description.


推荐阅读