3

How can I 'LEFT OUTER JOIN' or 'LEFT JOIN' using Views in Drupal 7.

Here is what I'm trying to do, using an example from Wikipedia:

I have 2 content types: Employee's and Department's (tables below)

The "DepartmentID" noted in the Employee Table below in my case would be the NodeID of the department from the "Department" custom content type.

enter image description here

How can I use Drupal 7's Views module to Display a list of employees with the department name pulled from another content type as noted in the graphic below?

(The SQL statement below is really what I'm hoping to be able to do with the Views module, the table is the output I'm hoping to achieve.)

enter image description here

6

In views 3 you have the relationships which manage JOINS between tables.
First you add your relation with the table and then in the next screen you can select Require this relationship.

Relationship Views3

If you check this checkbox, a LEFT JOIN will be made between the tables, if you uncheck it, it will generate a LEFT OUTER JOIN.

| improve this answer | |
  • I needed to install References (drupal.org/project/reference as well for D7, but this is exactly what I was looking for. Thank you @tostinni – Citricguy Oct 10 '11 at 10:04
  • what if now relationship is needed? for example in most visited content view there are all nodes including the ones which has not been visited till now. this does not need relationship – shekoufeh Jan 28 '16 at 8:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.