我在 Drupal 中创建的视图中得到了重复的节点。看来问题与在 node_access 表的视图中完成连接的方式有关。
使用开发,我看到以下查询:
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
与 node_access 表的连接导致其他记录重复,因为一个节点有多个 node_access 记录,一个具有 domain_site 领域,一个具有 domain_id 领域的记录。
数据看起来像这样(为简洁起见,删掉了一些列):
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
领域适合什么目的?这些记录是如何填充的,最重要的是,我该如何解决这个问题?SQL 是对的吗?