I'm getting duplicate nodes in a a view I've created in Drupal. It appears the issue is related to the way the join is done in views for the node\_access table.

Using devel, I see the following query:

```
    SELECT node.nid AS nid,
           node.language AS node_language,
           node_data_field_weekend.field_weekend_value AS node_data_field_weekend_field_weekend_value,
           node_data_field_weekend.field_weekend_value2 AS node_data_field_weekend_field_weekend_value2,
           node.type AS node_type,
           node.vid AS node_vid,
           node_data_field_weekend.field_weekend_loc_nid AS node_data_field_weekend_field_weekend_loc_nid
      FROM node node
 LEFT JOIN content_type_wwme_weekends node_data_field_weekend ON node.vid = node_data_field_weekend.vid
INNER JOIN node_access na                                     ON na.nid = node.nid
     WHERE (na.grant_view >= 1 AND
           (
           (na.gid = 0 AND na.realm = 'all') OR
           (na.gid = 0 AND na.realm = 'domain_site') OR
           (na.gid = 0 AND na.realm = 'domain_id'))) AND
           (
           (
           (node.type IN ('wwme_weekends')) AND
           (node.status <> 0 OR
           (node.uid = 0 AND 0 <> 0) OR 0 = 1)) AND
           (DATE_FORMAT(STR_TO_DATE(node_data_field_weekend.field_weekend_value, '%Y-%m-%dT%T'), '%Y-%m-%d') > '2010-01-10') )
  ORDER BY node_data_field_weekend_field_weekend_value ASC LIMIT 0, 5

```

The join to the node\_access table is causing the other records to duplicate because there are multiple node\_access records to a node, one with the realm of domain\_site and one record with the realm of domain\_id. 

The data sort of looks like this (with some columns cut for brevity):

```
nid     gid    realm        grant_view  grant_update    grant_delete
73      0      domain_id    1           1               1
73      0      domain_site  1           0               0
988     0      domain_id    1           1               1
988     0      domain_site  1           0               0
90      0      domain_id    1           1               1

```

What purpose does the realm fit? How are these records populated, and most importantly, how can I fix this? Is the SQL right?