Table_A has entity_id
Table_B has a related entity_id with attribute_id = 1
Table_B has a related entity_id with attribute_id = 2
SELECT Table_B.value
FROM Table_A
LEFT JOIN Table_B
ON Table_A.entity_id = Table_B.entity_id
WHERE Table_A.date = '2012-7-30 00:00:00'
AND Table_B.attribute_id = 1
I would like to get attribute_id = 1 and attribute_id = 2 into one query.
You can join Table_B a second time and use AS to give it a new name (an alias).
You can also move the attribute criteria to make it a little clearer what you’re up to: