Reputation: 27
I have some code here working well with an outer join.
It just appends a record from another table with a common field (entity-id) but for a specific record type "87".
My problem is that I want to also pull additional individual records from the same table with other record types "178" and "675" in the same SELECT statement.
Can I achieve this with a JOIN, or am I barking up the wrong tree????
SELECT
tempdb.Entity_id,
tempdb.SKU,
tempdb.Description,
Entity_Varchar.value AS ImageURL
FROM
tempdb
LEFT OUTER JOIN Entity_Varchar ON tempdb.entity_id = Entity_Varchar.entity_id AND Entity_Varchar.attribute_id = '87'
Upvotes: 0
Views: 36
Reputation: 1271151
You can extend the filtering condition for the record types you want:
SELECT t.Entity_id, t.SKU, t.Description,
ev.value AS ImageURL
FROM tempdb t LEFT JOIN
Entity_Varchar ev
ON t.entity_id = ev.entity_id AND
ev.attribute_id IN ('87', '178', '675');
Upvotes: 1