Hello,
I just upgraded my Drupal 6.9 installation to Drupal 6.10, and I started getting this error
user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DISTINCT(node.nid), node_data_field_thumb.field_thumb_fid AS node_data_field_' at line 1 query: SELECT DISTINCT(node.nid) AS DISTINCT(node.nid), node_data_field_thumb.field_thumb_fid AS node_data_field_thumb_field_thumb_fid, node_data_field_thumb.field_thumb_list AS node_data_field_thumb_field_thumb_list, node_data_field_thumb.field_thumb_data AS node_data_field_thumb_field_thumb_data, node.type AS node_type, node.vid AS node_vid, node.title AS node_title, node_data_field_excerpt.field_excerpt_value AS node_data_field_excerpt_field_excerpt_value, node_data_field_excerpt.field_excerpt_format AS node_data_field_excerpt_field_excerpt_format, node_revisions.timestamp AS node_revisions_timestamp FROM node node LEFT JOIN term_node term_node ON node.vid = term_node.vid INNER JOIN term_data term_data ON term_node.tid = term_data.tid LEFT JOIN content_field_thumb node_data_field_thumb ON node.vid = node_data_field_thumb.vid LEFT JOIN content_field_excerpt node_data_field_excerpt ON node.vid = node_data_field_excerpt.vid LEFT JOIN node_revisions node_revisions ON node.vid = node_revisions.vid WHERE (node.type in ('articles', 'book', 'case_study', 'interview', 'journal_issue', 'news', 'tool', 'webcast')) AND (node.status <> 0) AND (term_data.name = 'Featured') ORDER BY node_revisions_timestamp DESC LIMIT 0, 3 in D:\wamp\www\mnpv\marketingnpv\sites\all\modules\views\includes\view.inc on line 731.
All was working fine with Drupal 6.9, this happened as soon as I upgraded drupal to Drupal 6.10.
This seems to be some issue with drupal core. This was reported before as an issue in earlier versions of drupal. But this seems to be alive even in the latest version of drupal i.e. Drupal 6.10
This bug was reported here before: http://drupal.org/node/351341
There is some issue with the distinct keyword, drupal tries to put the aliases in the query with same name as fields, and when the field is with distinct keyword, it puts the distinct in the alias too.
Comments
Comment #1
finedesign commentedI get a similar issue when trying to set distinct to "yes" in a views block
using Drupal 6.10
Comment #2
dave reidDuplicate of #284392: db_rewrite_sql causing issues with DISTINCT
Comment #3
yasir farooqui commentedThanks Dave Reid for referring me to that post. It really helped me. And applying the patch provided in the 24th post of that thread, solved my issue.
But it seems an issue in the core, so hope that it should be fixed in core, rather than applying patches etc.
Thanks