I am trying to add DISTINCT to a view, and for example I chose the default content view.

I expect that it would add DISTINCT(id), but the query does not change at all. Why is it not added?

enter image description here


Trying to do another basic View that shows one node type in a REST display. It uses the Entity plugin and no fields. I tried to set DISTINCT, but look at the query:

SELECT DISTINCT date_recur__node__field_event_date.field_event_date_value AS date_recur__node__field_event_date_field_event_date_value, node_field_data.nid AS nid
{node_field_data} node_field_data
LEFT JOIN {date_recur__node__field_event_date} date_recur__node__field_event_date ON node_field_data.nid = date_recur__node__field_event_date.entity_id
WHERE (node_field_data.status = '1') AND (node_field_data.type IN ('event'))
ORDER BY date_recur__node__field_event_date_field_event_date_value ASC

This obviously doesn't work. I am not even setting the date value anywhere in the query, how is this getting in there?

  • This is what D7 shows while on D8 there is no change at all. So looks to me that this is a bug. – No Sssweat Jul 21 '17 at 20:51
  • Ok just did the test in a new view (I created a new view) on D8 and the DISTINCT does get added here. So looks like for some reason it does not work on the already existing "Content" view. – No Sssweat Jul 21 '17 at 20:57
  • Having the same problem on v8.4.3 - have you found a solution meanwhile? I've a very simple view of media entities containing only one field, yet I can't get an output without duplicates. – Hudri Dec 12 '17 at 10:30
  • Sorry, not the same problem... the distinct is getting added to the query, problem is that the media ID is included in the select, even though the field is not selected – Hudri Dec 12 '17 at 11:32
  • Still doesn't work. Updating original post. – Kevin Mar 2 '18 at 16:39

Your Answer

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

Browse other questions tagged or ask your own question.