How do I do something similar in Views with the below SQL query?
select nid,
title AS title1,
type AS node_type,
(select title from node,
field_data_field_node_reference_id
where
node.nid = field_data_field_node_reference_id.field_node_reference_id_target_id
AND
field_data_field_node_reference_id.entity_id = 1)
AS title2,
(select nid from node,
field_data_field_node_reference_id
where
node.nid = field_data_field_node_reference_id.field_node_reference_id_target_id
AND
field_data_field_node_reference_id.entity_id = 1)
AS nid2
from node
where nid=1;
The output in MySQL would be:
nid | title1 | node_type | title2 | nid2
1 | Some Title | MyNode | Another Title | 69
As you can see, they share a relationship by a field called 'field_node_reference_id_target_id'. Both values, 'title1' and 'title2', are from the same table called 'node'. I would like to avoid writing my own SQL queries, so is there a way to get views to display a similar output (e.g. node titles in the same row that share a relationship)?