Add a relationship to a view
When you first create a view you select the base table from options such as Comments, Content, and Taxonomy terms. This cannot be changed later. After that selection you will only be able to select fields from that base table. For example, with a Content view, you can get the User ID of the author, but not the author's username. To get that information you will need to create a Relationship to join those two tables. With the connection of User ID, you can get the author's username from the User table.
- Navigate to the edit screen of a view (for example, admin/structure/views/view/MYVIEWNAME ) In this case we're editing a Content listing.
- In the right column, click Advanced.
- In the Relationships area, click Add.
- There are many tables you can join to the content listing. In this case, search for "author" options, and select Content: Content author. Click Apply.
- Next you can set the administrative title, though the default should be sensible enough. You can also opt to "Require this relationship. This will hide content which doesn't have the relationship. Click Apply.
- Under Fields click Add.
- Search for your chosen relationship, such as User. Now you will have more fields available from the joined table, in this case the User table. Select User: Name. Click Apply.
- Next you can configure how the field displays. The defaults in this case will append a field label and make the field a link to the user. Change the label to Author. Click Apply.
- Check your preview to see your content listing, including the author's username.