You need to use an INNER JOIN clause, so something like:
SELECT A1.attribute1 AS atr1
FROM module.entity1 as A
INNER JOIN module.entity1_entity2/module.entity2 as B
WHERE
A.atr1 = 'string'
The OQL INNER JOIN over association will be automatically interpreted by the SQL engine of Mendix as an A.ID on B.ID join