Posted by Mandakini_Kumari on March 16, 2011 at 6:49am
I need help in creating view.
I have two content type(profile and patient_services ) reference nid to connect two are nid and field_patient_service_reference_nid.
I need to display data from both table
where content_type_profile.nid = content_type_patient_services.field_patient_service_reference_nid
Please let me know how to get this result.

Comments
You ll need to user
You ll need to use Views Relationships to bring in the data from the second table.
I would recommend you get some idea about how Views Relationships work .. before trying it out. Its a lil tough to understand but once you have .. then you can exploit to the full
This could help
http://gotdrupal.com/videos/drupal-views-relationships
rajarju
field_patient_service_referen
field_patient_service_reference_nid is a CCK field (probably node reference) and you are running D6, is that right?
use relationships in views
You ca contact me in case you need more details, but relationships is the way to go in such a case.
Use Relationships
Hi, You should use Relationships for this.
How to use Relationships in Views.
1. Select Add Relationship by click on '+' Icon
2. Select the reference field, In your case field_patient_service_reference_nid
3. Then While adding fields from Fields Section, You will have one new option called Relationship with options you created above.
4. So Select the relation to get the filtered content
Regards
Venkat.
use view realtionship
Realtionships is the better way to get that
I tryied relationship but won't worked
this is sql
SELECT node.nid AS nid,
node_data_field_legal_name.field_legal_name_value AS node_data_field_legal_name_field_legal_name_value,
node.type AS node_type,
node.vid AS node_vid,
users.uid AS users_uid,
node_data_field_legal_name.field_gender_value AS node_data_field_legal_name_field_gender_value,
node_data_field_legal_name.field_lead_status_value AS node_data_field_legal_name_field_lead_status_value,
node.created AS node_created
FROM node node
LEFT JOIN content_type_patient_services node_data_field_patient_service_reference ON node.vid = node_data_field_patient_service_reference.vid
LEFT JOIN node node_node_data_field_patient_service_reference ON node_data_field_patient_service_reference.field_patient_service_reference_nid = node_node_data_field_patient_service_reference.nid
INNER JOIN content_type_patient_services node_node_data_field_patient_service_reference_node_data_field_provider ON node_node_data_field_patient_service_reference.vid = node_node_data_field_patient_service_reference_node_data_field_provider.vid
LEFT JOIN content_type_profile node_data_field_legal_name ON node.vid = node_data_field_legal_name.vid
INNER JOIN users users ON node.uid = users.uid
WHERE (node_node_data_field_patient_service_reference_node_data_field_provider.field_provider_uid = '15') AND (node.status <> 0) AND (node.type in ('profile'))
ORDER BY node_data_field_legal_name_field_legal_name_value ASC
Mandakini Kumari
True! Relationships is the
True! Relationships is the way to get the desired result.
But, someone mentioned it earlier that it is a little difficult to understand. Actually, its not all that difficult to understand. Since you seem to understand relationships (in general sense and not in Drupal's and Views sense), it would be easy for you to see how relationships work.
Also, David Mercer's book Drupal 7 has a brief and easy to understand guide on Views which also talks about relationships. You can refer to that!
Vaidik Kapoor
Relationship
where content_type_profile.nid = content_type_patient_services.field_patient_service_reference_nid,
in that case, you export the view, check the query part, excute the query what are you looking for , replace the query which you need, then
import the code as view.
This is the only chance to get your result.