How can I return d.title or u.name in the outer SELECT clause?
SELECT c.id, c.name
FROM components c
INNER JOIN publications p
ON c.id = p.component_id
AND p.document_id IN
(SELECT d.id FROM documents d WHERE user_id IN
(SELECT u.id FROM users u WHERE u.brand_id IN (39, 41)
)
)
I get this error when I throw d.title in the top line:
missing FROM-clause entry for table "d" LINE 1
The package I'm using needs these values returned on the top line to make any use out of them in the result.
Structure
A User has many Documents, and Publications is the join table between Documents and Components.